467,915 Members | 1,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

Count and group of a date column

I have the need to do a count of all open calls daily grouped for the hour

So for example:

10-11:00 - 5 open calls.
11-12:00 - 10 open calls

I have created the following that works to an extent but not like above.

CONVERT(VARCHAR(13), datumaangemeld, 120) Date_Hour,
COUNT(*) count_Records

FROM dbo.incident

WHERE ref_actiedoordynanaam = 'smith, david' and gereed = 0

GROUP By CONVERT(VARCHAR(13), datumaangemeld, 120)

Its producing results of :
Date_Hour Count
2008-09-09 15 1
2008-09-09 16 1
2008-09-09 18 1
2008-09-10 12 1
2008-09-11 12 1

Which is not ideal
Not sure how to get what I want

Any help appreciated ...


Sep 12 '08 #1
  • viewed: 1202
1 Reply
Expert 2GB
Couple of Questions regarding your requirement:

1. You should be GROUPING BY date-month-year-HR incase if you have same date of differnt years to avoid incorrect results
2. You said you want hourly count,so in case if the time is 11.15 then this call will be counted in !!o clock calls or 12 o clock calls? I think you should be looking at 1 HR range to find the COUNT of calls,something like 11-12,12-13 and so on?
Sep 15 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Sjef ten Koppel | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.