Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Average of volume by weekday and hour over range - response (1) by dnoeth

$
0
0

You group both times by the same columns, if i understodd you correctly you have to group by date/hour first and then by weekday:

SELECT 
   creation_dt (FORMAT 'eee') (CHAR(3))
   ,AVG(CASE WHEN "hour" = 0 THEN cnt END) AS "00:00"
   ,AVG(CASE WHEN "hour" = 1 THEN cnt END) AS "01:00"
   ,AVG(CASE WHEN "hour" = 2 THEN cnt END) AS "02:00"
...
FROM
 (      
   SELECT
      CAST(creation_ts AS DATE) AS creation_dt
      ,EXTRACT(HOUR FROM creation_ts) AS "hour"
      ,COUNT(*) AS cnt
   FROM calls_table
   GROUP BY 1,2
 ) AS dt     
GROUP BY 1

 
Dieter


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>