Grouping by time period
-
I'm trying to create a query that counts records based on time periods. I'm querying two tables, one containing SubmittedDate, the other CompletedDate. I'm using DateDiff to calculate the time difference between the two. What I want to do is end up w/ a count for mulitple periods of time like.... < 2 Hours 3 2 - 4 Hours 6 4-8 Hours 10 1 Day 12 1 - 3 Days 8 5 Days 4 > 5 Days 2 Any ideas? Jeff Martin My Blog
-
I'm trying to create a query that counts records based on time periods. I'm querying two tables, one containing SubmittedDate, the other CompletedDate. I'm using DateDiff to calculate the time difference between the two. What I want to do is end up w/ a count for mulitple periods of time like.... < 2 Hours 3 2 - 4 Hours 6 4-8 Hours 10 1 Day 12 1 - 3 Days 8 5 Days 4 > 5 Days 2 Any ideas? Jeff Martin My Blog
You could write a UDF (User defined function) that returns the time period and then use that in your query.
Cada uno es artifice de su ventura WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums