First i would simplify the calculation on LOG_TIME, why do you cast every part to a string?
CAST((log_time (FORMAT 'hh:mi:ss')) AS CHAR(8)) AS HOUR_MIN_SEC
You might also avoid typecasting to a string:
log_time - ((EXTRACT(SECOND FROM log_time) MOD 1) * INTERVAL '1' SECOND)
Based on your query i'm not shure if you want the count per minute, then simply remove the "mod 1" (or change the FORMAT).
And then it's just a QUALIFY:
SELECT
LOG_DATE,
log_time - ((EXTRACT(SECOND FROM log_time) MOD 1) * INTERVAL '1' SECOND) AS HOUR_MIN_SEC,
COUNT(*) AS Downloads_Per_Second
FROM CDN_RQST_EVT
WHERE LLNW_REDRCT_STAT_CODE IN ('DVR%20STATUS%3A%20DOWNLOAD_COMPL',' DOWNLOAD_COMPLETED')
AND LOG_DATE BETWEEN '2013-03-11' AND '2013-03-17'
--AND LOG_TIME < '09:00:00'
GROUP BY 1,2
QUALIFY
ROW_NUMBER()
OVER (PARTITION BY Log_Date, EXTRACT(HOUR FROM HOUR_MIN_SEC)
ORDER BY Downloads_Per_Second DESC) = 1
Dieter
First i would simplify the calculation on LOG_TIME, why do you cast every part to a string?
You might also avoid typecasting to a string:
Based on your query i'm not shure if you want the count per minute, then simply remove the "mod 1" (or change the FORMAT).
And then it's just a QUALIFY:
Dieter