Für mich ist es oft wichtig, wieviele Zugriffe, Einträge oder einfach ein Zeitstempel pro Stunde und Tag vorkommt. Dies kann zum Beispiel interessant sein, wenn ich wissen will wann am wenigsten Zugriffe auf eine Applikation erfolgen, damit ich ein Wartungsfenster plannen kann.
Tabelle: loginfo (mit Spalte log_dat)
Im Output ist in den ersten Spalten das Datum und die Anzahl Einträge pro Tag beschrieben. In den folgenden Spalten sind, pro Stunde, die Anzahl der Einträge beschrieben.
select d datum, count(*) cnt, sum(decode(h, 0,1,null))h00, sum(decode(h, 1,1,null))h01, sum(decode(h, 2,1,null))h02, sum(decode(h, 3,1,null))h03, sum(decode(h, 4,1,null))h04, sum(decode(h, 5,1,null))h05, sum(decode(h, 6,1,null))h06, sum(decode(h, 7,1,null))h07, sum(decode(h, 8,1,null))h08, sum(decode(h, 9,1,null))h09, sum(decode(h,10,1,null))h10, sum(decode(h,11,1,null))h11, sum(decode(h,12,1,null))h12, sum(decode(h,13,1,null))h13, sum(decode(h,14,1,null))h14, sum(decode(h,15,1,null))h15, sum(decode(h,16,1,null))h16, sum(decode(h,17,1,null))h17, sum(decode(h,18,1,null))h18, sum(decode(h,19,1,null))h19, sum(decode(h,20,1,null))h20, sum(decode(h,21,1,null))h21, sum(decode(h,22,1,null))h22, sum(decode(h,23,1,null))h23 from (select to_char(log_dat,'yyyy-mm-dd, DY') d, to_char(log_dat,'hh24') h from loginfo where log_dat >= trunc(add_months(sysdate, -12))) group by d order by 1 desc;