RIAS
asked on
Sql query for update and inner join
Hi,
I have a inner join sql query to get startDate from table Personal_details and EndDate from table'CU_CABLES_PRES_PEN_D ETAIL'
The requirement is to have start date one day after end date.If a null Date is found for end date I need to insert the value in it.
How can I create a query to achieve this
Query inner join:
SELECT a.refno, a.DATELEFT as dateleft , b.CU_CABPPD_StartDate as startDate FROM PERSONAL_DETAILS as a INNER JOIN CU_CABLES_PRES_PEN_DETAIL as b ON a.REFNO = b.refno
The data current has some null end dates which need to be filled in appropriately.
Some records where end date is equal to startdate
Some records where end date is after startdate
Many thanks in advance
Cheers
Refno StartDate EndDate
10001 01/08/2005 00:00 NULL
10008 01/08/2005 00:00 NULL
10009 12/11/2001 00:00 11/11/2001 00:00
10010 18/08/2001 00:00 17/08/2001 00:00
10015 01/08/2005 00:00 NULL
10017 01/02/2002 00:00 31/01/2002 00:00
10018 01/08/2005 00:00 31/07/2005 00:00
10020 01/11/2002 00:00 31/10/2002 00:00
10021 05/02/2001 00:00 04/02/2001 00:00
10022 06/02/2001 00:00 06/02/2001 00:00
10023 07/02/2001 00:00 08/02/2001 00:00
I have a inner join sql query to get startDate from table Personal_details and EndDate from table'CU_CABLES_PRES_PEN_D
The requirement is to have start date one day after end date.If a null Date is found for end date I need to insert the value in it.
How can I create a query to achieve this
Query inner join:
SELECT a.refno, a.DATELEFT as dateleft , b.CU_CABPPD_StartDate as startDate FROM PERSONAL_DETAILS as a INNER JOIN CU_CABLES_PRES_PEN_DETAIL as b ON a.REFNO = b.refno
The data current has some null end dates which need to be filled in appropriately.
Some records where end date is equal to startdate
Some records where end date is after startdate
Many thanks in advance
Cheers
Refno StartDate EndDate
10001 01/08/2005 00:00 NULL
10008 01/08/2005 00:00 NULL
10009 12/11/2001 00:00 11/11/2001 00:00
10010 18/08/2001 00:00 17/08/2001 00:00
10015 01/08/2005 00:00 NULL
10017 01/02/2002 00:00 31/01/2002 00:00
10018 01/08/2005 00:00 31/07/2005 00:00
10020 01/11/2002 00:00 31/10/2002 00:00
10021 05/02/2001 00:00 04/02/2001 00:00
10022 06/02/2001 00:00 06/02/2001 00:00
10023 07/02/2001 00:00 08/02/2001 00:00
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER