Pivot query in Oracle
report generated each hour wise for zone and circle in the following query
select *
from (
select ZONE,CIRCLE,TO_NUMBER(to_char(ococ_dt,'hh24')) grp,count(*) cnt
from OCOC_CAF_JAN2022
group by ZONE,CIRCLE,TO_NUMBER(to_char(ococ_dt,'hh24'))
)
pivot(
sum(cnt)
for grp in ( 0 as "00-01",1 as "01-02",2 as "02-03",
3 as "03-04",4 as "04-05",5 as "05-06",
6 as "06-07",7 as "07-08",8 as "08-09",
9 as "09-10",10 as "10-11",11 as "11-12",
12 as "12-13",13 as "13-14",14 as "14-15",
15 as "15-16",16 as "16-17",17 as "17-18",
18 as "18-19",19 as "19-20",20 as "20-21",
21 as "21-22",22 as "22-23",23 as "23-24"
) )
ORDER BY 1,2;
Output
Tags:
Oracle
Nice thank you
ReplyDelete