m@rc-lenzin

Wenn etwas schief geht, dann freu dich. Das sind die Geschichten die dir in Erinnerung bleiben werden

oracle – summary per hour

Query:

select  d,count(*),
        sum(ds(h, 0))h00,sum(ds(h, 1))h01,    sum(ds(h, 2))h02,sum(ds(h, 3))h03,
        sum(ds(h, 4))h04,sum(ds(h, 5))h05,    sum(ds(h, 6))h06,sum(ds(h, 7))h07,
        sum(ds(h, 8))h08,sum(ds(h, 9))h09,    sum(ds(h,10))h10,sum(ds(h,11))h11,
        sum(ds(h,12))h12,sum(ds(h,13))h13,    sum(ds(h,14))h14,sum(ds(h,15))h15,
        sum(ds(h,16))h16,sum(ds(h,17))h17,    sum(ds(h,18))h18,sum(ds(h,19))h19,
        sum(ds(h,20))h20,sum(ds(h,21))h21,    sum(ds(h,22))h22,sum(ds(h,23))h23
  from (select  to_char(created_dat,'yyyy-mm-dd, DY')d,
                to_char(created_dat,'hh24') h 
          from  imp_tbl_test
          where state = 88 
          and   created_dat >= trunc(sysdate -120))
  group by d
  order by 1 desc;

Resultat:
summaryPerDay

Weiter Beitrag

Zurück Beitrag

© 2025 m@rc-lenzin

Thema von Anders Norén