The select decc admitted, objtype, objname, objid, usrid, timesheetid, timetypename, hour1, houradd1, flag1, aflag1, hour2, houradd2, flag2, aflag2, hour3, houradd3, flag3, aflag3, hour4, houradd4, flag4,
Aflag4 hour5, houradd5 flag5, aflag5, hour6, houradd6, flag6, aflag6, hour7, houradd7, flag7, aflag7, hour0, houradd0
The from (select '1' decc admitted,
0 objtype,
'to develop a' objname,
Pb. Type objid,
0 usrid,
0 timesheetid,
"' timetypename,
The sum (case when timesheetdetailid=1 then WTD. The manhour else 0 end) hour1,
The sum (case when timesheetdetailid=1 then WTD. Manovertime else 0 end) houradd1,
0 flag1,
0 aflag1,
The sum (case when timesheetdetailid=2 then WTD. The manhour else 0 end) hour2,
The sum (case when timesheetdetailid=2 then WTD. Manovertime else 0 end) houradd2,
0 flag2,
0 aflag2,
The sum (case when timesheetdetailid=3 then WTD. The manhour else 0 end) hour3,
The sum (case when timesheetdetailid=3 then WTD. Manovertime else 0 end) houradd3,
0 flag3,
0 aflag3,
The sum (case when timesheetdetailid=4 then WTD. The manhour else 0 end) hour4,
The sum (case when timesheetdetailid=4 then WTD. Manovertime else 0 end) houradd4,
0 flag4,
0 aflag4,
The sum (case when timesheetdetailid=5 then WTD. The manhour else 0 end) hour5,
The sum (case when timesheetdetailid=5 then WTD. Manovertime else 0 end) houradd5,
0 flag5,
0 aflag5,
The sum (case when timesheetdetailid=6 then WTD. The manhour else 0 end) hour6,
The sum (case when timesheetdetailid=6 then WTD. Manovertime else 0 end) houradd6,
0 flag6,
0 aflag6,
The sum (case when timesheetdetailid=7 then WTD. The manhour else 0 end) hour7,
The sum (case when timesheetdetailid=7 then WTD. Manovertime else 0 end) houradd7,
0 flag7,
0 aflag7,
The sum (WTD. Manhour) hour0,
The sum (WTD. Manovertime) houradd0
The from wk_timesheet wt
The left outer join wk_timesheetdetail WTD
On wt. Timesheetid=WTD. Timesheetid
And (manhour & gt; 0 or manovertime & gt; 0)
The left outer join org_userinfo ou
On wt. Userid=ou. Userid
The left outer join pj_baseinfo pb
On wt. Projectid=pb. Projectid
Where pb. Type=0
And (WTD. Submitstate=1 or WTD. Submitstate=2)
And wt. Userid in (select u.u serid from org_userinfo u left outer join dpt_departmentaccess d on u.a ttachdepartmentid=d.d epartmentid left outer join org_role a on a.r oleid=d.r oleid where a.r oletypeid=5 and Amy polumbo rincipal=1)
And wt. Timestartdate=to_date (' 2018-01-15 ', '- dd yyyy - MM)
Group by pb. Type the
Union all
Select '11' decc admitted,
0 objtype,
Ou. Username objname,
Pb. Type objid,
Wt. Userid usrid,
0 timesheetid,
"' timetypename,
The sum (case when timesheetdetailid=1 then WTD. The manhour else 0 end) hour1,
The sum (case when timesheetdetailid=1 then WTD. Manovertime else 0 end) houradd1,
0 flag1,
0 aflag1,
The sum (case when timesheetdetailid=2 then WTD. The manhour else 0 end) hour2,
The sum (case when timesheetdetailid=2 then WTD. Manovertime else 0 end) houradd2,
0 flag2,
0 aflag2,
The sum (case when timesheetdetailid=3 then WTD. The manhour else 0 end) hour3,
The sum (case when timesheetdetailid=3 then WTD. Manovertime else 0 end) houradd3,
0 flag3,
0 aflag3,
The sum (case when timesheetdetailid=4 then WTD. The manhour else 0 end) hour4,
The sum (case when timesheetdetailid=4 then WTD. Manovertime else 0 end) houradd4,
0 flag4,
0 aflag4,
The sum (case when timesheetdetailid=5 then WTD. The manhour else 0 end) hour5,
The sum (case when timesheetdetailid=5 then WTD. Manovertime else 0 end) houradd5,
0 flag5,
0 aflag5,
The sum (case when timesheetdetailid=6 then WTD. The manhour else 0 end) hour6,
The sum (case when timesheetdetailid=6 then WTD. Manovertime else 0 end) houradd6,
0 flag6,
0 aflag6,
The sum (case when timesheetdetailid=7 then WTD. The manhour else 0 end) hour7,
The sum (case when timesheetdetailid=7 then WTD. Manovertime else 0 end) houradd7,
0 flag7,
0 aflag7,
The sum (WTD. Manhour) hour0,
The sum (WTD. Manovertime) houradd0
The from wk_timesheet wt
The left outer join wk_timesheetdetail WTD
On wt. Timesheetid=WTD. Timesheetid
And (manhour & gt; 0 or manovertime & gt; 0)
The left outer join org_userinfo ou
On wt. Userid=ou. Userid
The left outer join pj_baseinfo pb
On wt. Projectid=pb. Projectid
Where pb. Type=0
And (WTD. Submitstate=1 or WTD. Submitstate=2)
And wt. Userid in (select u.u serid from org_userinfo u left outer join dpt_departmentaccess d on u.a ttachdepartmentid=d.d epartmentid left outer join org_role a on a.r oleid=d.r oleid where a.r oletypeid=5 and Amy polumbo rincipal=1)
And wt. Timestartdate=to_date (' 2018-01-15 ', '- dd yyyy - MM)
Group by pb. Type, ou. The username, wt. Userid
Union all
Select '111' decc admitted,
0 objtype,
TB. Taskname objname,
Pb. Type objid,
Wt. Userid usrid,
Wt. Timesheetid,
CD. Paraname timetypename,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull