Hi all,
I've had a long look through the archives here for an answer to my problem with no luck. Here's the problem:
I have a table of users and a time difference between start time and end time in the system (measured in minutes). Eg (simplified):
UserNo TimeDifference
--------------- --------------
+01 0
+02 0
+05 1
+99 5
+200 12
+23434 12
+232 25
I want to SELECT from this table using GROUP BY TimeDifference. Eg:
SELECT TimeDifference, COUNT(UserNo) FROM #timedifftable GROUP BY TimeDifference ORDER BY TimeDifference
This would give
0 2
1 1
5 1
(and so on)
What I really want is to GROUP BY ranges of TimeDifference - so I want to count the amount of users in ranges of 10 minutes. eg, I want to get this result:
TimeDifference Users
0-9 4
10-19 2
20-29 1
and so on
The actual table is very big so I don't want to have to specify each range in the select - especially since I may need to change the ranges used etc.
Any help appreciated.
I've had a long look through the archives here for an answer to my problem with no luck. Here's the problem:
I have a table of users and a time difference between start time and end time in the system (measured in minutes). Eg (simplified):
UserNo TimeDifference
--------------- --------------
+01 0
+02 0
+05 1
+99 5
+200 12
+23434 12
+232 25
I want to SELECT from this table using GROUP BY TimeDifference. Eg:
SELECT TimeDifference, COUNT(UserNo) FROM #timedifftable GROUP BY TimeDifference ORDER BY TimeDifference
This would give
0 2
1 1
5 1
(and so on)
What I really want is to GROUP BY ranges of TimeDifference - so I want to count the amount of users in ranges of 10 minutes. eg, I want to get this result:
TimeDifference Users
0-9 4
10-19 2
20-29 1
and so on
The actual table is very big so I don't want to have to specify each range in the select - especially since I may need to change the ranges used etc.
Any help appreciated.