1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| with req as
(
select to_date('01/01/2010 08:13:15','DD/MM/YYYY HH24:MI:SS') as LOGON_DAY,'DUPOND' as LOGIN from dual union all
select to_date('01/01/2010 08:15:40','DD/MM/YYYY HH24:MI:SS') as LOGON_DAY,'DURAND' as LOGIN from dual union all
select to_date('01/01/2010 09:15:12','DD/MM/YYYY HH24:MI:SS') as LOGON_DAY,'DURAND' as LOGIN from dual union all
select to_date('02/01/2010 10:12:15','DD/MM/YYYY HH24:MI:SS') as LOGON_DAY,'MARTIN' as LOGIN from dual
),
reqminday as
(
select min(LOGON_DAY) as min from req
),
reqday as
(
select min-1 + level as day from reqminday
connect by level <=
((select max(LOGON_DAY) from req) - (select min(LOGON_DAY) from req)+1)
)
,
reqminheure as
(
select min(to_char(LOGON_DAY,'HH24')) as min from req
),
reqheure as
(
select min-1 + level as heure from reqminheure
connect by level <=
((select max(to_char(LOGON_DAY,'HH24')) from req) - (select min(to_char(LOGON_DAY,'HH24')) from req)+1)
),
reqCalendrier as
(
select rd.day day ,rh.heure heure from reqday rd,reqheure rh
),
avantPivot as (
select day, heure ,sum(total) as total from(
select
day,
heure,
decode(to_char(LOGON_DAY,'DDMMYYYY'),to_char(rc.day,'DDMMYYYY'),decode(to_char(LOGON_DAY,'HH24'),rc.heure,1,0),0) total
from reqCalendrier rc,req r
)
group by day, heure
)
select to_char(day,'DD/MM/YYYY') as dt,
--sum(decode(heure,'7',total,0)) as "08h00",
sum(decode(heure,'8',total,0)) as "08h00",
sum(decode(heure,'9',total,0)) as "09h00",
sum(decode(heure,'10',total,0)) as "10h00"
--sum(decode(heure,'11',total,0)) as "10h00"
--sum(decode(heure,'12',total,0)) as "12h00"
from avantPivot
group by day
order by day |
Partager