1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| WITH t AS
(
SELECT
to_date('14/09/2009', 'dd/mm/yyyy') + (level - 1) * 1/24 * 4 AS borninf,
to_date('14/09/2009', 'dd/mm/yyyy') + (level) * 1/24 * 4 - (1/(24*60*60)) AS bornsup
FROM dual
CONNECT BY level <= (trunc(sysdate) - to_date('14/09/2009'))*24/4
)
SELECT
to_char(t.borninf,'dd/mm/yyyy') as jour,
to_char(t.borninf,'hh24:mi:ss') as heure_debut,
to_char(t.bornsup,'hh24:mi:ss') as heure_fin,
count(*) as nb_ligne
from t
join presence p
ON to_date(p.datej || p.heure,'dd/mm/yyyyhh24:mi:ss') between t.borninf and t.bornsup
GROUP BY to_char(t.borninf,'dd/mm/yyyy'), to_char(t.borninf,'hh24:mi:ss'), to_char(t.bornsup,'hh24:mi:ss')
order by to_char(t.borninf,'dd/mm/yyyy'), to_char(t.borninf,'hh24:mi:ss'), to_char(t.bornsup,'hh24:mi:ss') |
Partager