We have a table that records a timestamp as different events take place, I am trying to group these into 15 minute buckets taking data from the last rolling calendar month.
I think I'm 99% of the way there, but I'm stumped/confused on one last element. The idea being that we can then see where our busy periods of the day are.
Code:
SELECT DATEADD("n", CP.FifteenMinutePeriod * 15, CDATE("08:00:00")) as Period, CP.FullName, SUM(CP.Calls)
FROM
(SELECT P.FifteenMinutePeriod, P.FullName, COUNT(T.FullName) as Calls
FROM
(SELECT
DATEDIFF("n",CDATE("08:00:00"),TimeValue(T.StartTime)) / 15 as FifteenMinutePeriod, T.FullName
FROM LifeCycleData as T
WHERE T.EventType = 'In Queue' AND T.StartTime >= DATEADD("m",-1,DATE())) as P
GROUP BY P.FifteenMinutePeriod, T.FullName) as CP
GROUP BY DATEADD("n", CP.FifteenMinutePeriod * 15, CDATE("08:00:00")), FullName
This code doesn't actually seem to group by 15 minutes, I've tried different values instead of 15 but it doesn't appear to make a difference, and I'm sure I've gone code blind now having spent all of yesterday and today starting at this, playing around and tinkering.