Hi I am trying to derive the correct absence startTime of all exceptions (absence codes)from the following SQL statement. But, I am getting the following results with all start times beginning at 00:00 and ending 02:00X. With the following SQL statement, how can retrieve the correct "da.absTimeBegin and a."absTimeEnd"?
Thanks guys.
1000010705,,05/10/2013,00:00,02:00X,08:26,VAC
1000010705,,05/13/2013,00:00,02:00X,08:26,VAC
1000010705,,05/14/2013,00:00,02:00X,08:26,VAC
1000010705,,05/15/2013,00:00,02:00X,08:26,VAC
1000010705,,05/16/2013,00:00,02:00X,08:26,VAC
1000010705,,05/17/2013,00:00,02:00X,08:26,VAC
1000010705,,05/25/2013,08:00,11:00A,03:00,PHYO
1000010705,,05/27/2013,00:00,02:00X,08:33,H
1000010705,,07/04/2013,00:00,02:00X,08:33,H
1000010705,,08/23/2013,00:00,02:00X,08:33,SK
1000010705,,08/26/2013,00:00,02:00X,08:33,SK
1000010705,,08/27/2013,00:00,02:00X,08:33,SK
select
(e."personnelID")||','||
trim(a."runNumber") ||','||
trim(To_Char(da."opDate", 'MM/DD/YYYY' ))||','||
trim(dbo.hh_mm(nvl(da."absTimeBegin",0)))||','||
trim(dbo.hh_mma(nvl(a."absTimeEnd",0)))||','||
trim(dbo.hh_mm(nvl(da."paidTime",0)))||','||
trim(da."absPayCode")
from "dailyAbsence" da , "absence" a, "employee" e, "employeeStatus" es
----where da."opDate" in ('16-dec-13','17-dec-13')and
where da."opDate" between SYSDATE -3 AND SYSDATE +3 and
a."emp_SID" = da."emp_SID" and a."absCode" = da."absCode" and a."absDateBegin" = da."absDateBegin" and a."absTimeBegin" = da."absTimeBegin" and
e."emp_SID" = da."emp_SID" and
es."emp_SID" = da."emp_SID" and es."dateEffective" <= da."opDate" and es."dateEnd" >= da."opDate"
union all
select
(e."personnelID")||','||
(detd."runNumber") ||','||
trim(To_Char(de."opDate", 'MM/DD/YYYY' ))||','||
trim('00:00A')||','||
trim('00:00A')||','||
trim(dbo.hh_MM(detd."paidTime"))||','||
trim(detd."payType")
from "dailyEmployeeTimeDetail" detd
INNER JOIN "employee" e ON e."emp_SID"= detd."emp_SID"
INNER JOIN "employeeStatus" es ON es."emp_SID"= detd."emp_SID" and es."dateEffective" <= detd."opDate" and es."dateEnd" >= detd."opDate"
inner join "dailyEmployee" de on de."opDate" = detd."opDate" and de."emp_SID" = detd."emp_SID"
----where detd."opDate" in ('16-dec-13','17-dec-13')and
where detd."opDate" between SYSDATE -3 AND SYSDATE +3 and detd."payType" not in ('GU','PL','RP','TR','BR','CO','DT','LRF','ME','NET', 'WOT','OE','OS','PLD','PL','RP','RT','LIN','SE','SDP','SIG4','SH','SL','SO','SP','STU','TE','TRF','TRN','TS','VLT','WE','WS','WT') and detd."paySource" <>'ABAT'
Thanks guys.
1000010705,,05/10/2013,00:00,02:00X,08:26,VAC
1000010705,,05/13/2013,00:00,02:00X,08:26,VAC
1000010705,,05/14/2013,00:00,02:00X,08:26,VAC
1000010705,,05/15/2013,00:00,02:00X,08:26,VAC
1000010705,,05/16/2013,00:00,02:00X,08:26,VAC
1000010705,,05/17/2013,00:00,02:00X,08:26,VAC
1000010705,,05/25/2013,08:00,11:00A,03:00,PHYO
1000010705,,05/27/2013,00:00,02:00X,08:33,H
1000010705,,07/04/2013,00:00,02:00X,08:33,H
1000010705,,08/23/2013,00:00,02:00X,08:33,SK
1000010705,,08/26/2013,00:00,02:00X,08:33,SK
1000010705,,08/27/2013,00:00,02:00X,08:33,SK
select
(e."personnelID")||','||
trim(a."runNumber") ||','||
trim(To_Char(da."opDate", 'MM/DD/YYYY' ))||','||
trim(dbo.hh_mm(nvl(da."absTimeBegin",0)))||','||
trim(dbo.hh_mma(nvl(a."absTimeEnd",0)))||','||
trim(dbo.hh_mm(nvl(da."paidTime",0)))||','||
trim(da."absPayCode")
from "dailyAbsence" da , "absence" a, "employee" e, "employeeStatus" es
----where da."opDate" in ('16-dec-13','17-dec-13')and
where da."opDate" between SYSDATE -3 AND SYSDATE +3 and
a."emp_SID" = da."emp_SID" and a."absCode" = da."absCode" and a."absDateBegin" = da."absDateBegin" and a."absTimeBegin" = da."absTimeBegin" and
e."emp_SID" = da."emp_SID" and
es."emp_SID" = da."emp_SID" and es."dateEffective" <= da."opDate" and es."dateEnd" >= da."opDate"
union all
select
(e."personnelID")||','||
(detd."runNumber") ||','||
trim(To_Char(de."opDate", 'MM/DD/YYYY' ))||','||
trim('00:00A')||','||
trim('00:00A')||','||
trim(dbo.hh_MM(detd."paidTime"))||','||
trim(detd."payType")
from "dailyEmployeeTimeDetail" detd
INNER JOIN "employee" e ON e."emp_SID"= detd."emp_SID"
INNER JOIN "employeeStatus" es ON es."emp_SID"= detd."emp_SID" and es."dateEffective" <= detd."opDate" and es."dateEnd" >= detd."opDate"
inner join "dailyEmployee" de on de."opDate" = detd."opDate" and de."emp_SID" = detd."emp_SID"
----where detd."opDate" in ('16-dec-13','17-dec-13')and
where detd."opDate" between SYSDATE -3 AND SYSDATE +3 and detd."payType" not in ('GU','PL','RP','TR','BR','CO','DT','LRF','ME','NET', 'WOT','OE','OS','PLD','PL','RP','RT','LIN','SE','SDP','SIG4','SH','SL','SO','SP','STU','TE','TRF','TRN','TS','VLT','WE','WS','WT') and detd."paySource" <>'ABAT'