G'day All
I have the following table:
I need to know the following:
How can I get a DISTINCT Count by hour of the User_ID and if the hour is between 22:00 and 05:00 and the user ID is Less than 2 then the USer_ID count for that hour should be 2
this need to be for all date in the database
The results should look something like this:
Thank you for your help in this matter
Cheers
Rich
A newbie to SQL
I have the following table:
Code:
User_ID Start_Date Start_Time Session_Type_ID
1,050 30/09/2004 00:00 01/01/1900 14:29 1
1,050 30/09/2004 00:00 01/01/1900 14:28 8
1,037 30/09/2004 00:00 01/01/1900 14:25 1
1,019 30/09/2004 00:00 01/01/1900 14:25 1
1,019 30/09/2004 00:00 01/01/1900 14:24 8
1,037 30/09/2004 00:00 01/01/1900 14:24 8
1,022 30/09/2004 00:00 01/01/1900 14:05 6
1,054 30/09/2004 00:00 01/01/1900 14:02 1
1,054 30/09/2004 00:00 01/01/1900 14:02 8
1,022 30/09/2004 00:00 01/01/1900 14:00 6
How can I get a DISTINCT Count by hour of the User_ID and if the hour is between 22:00 and 05:00 and the user ID is Less than 2 then the USer_ID count for that hour should be 2
this need to be for all date in the database
The results should look something like this:
Code:
Date 00 01 02 03 . . . 20 21 22 23
2004/09/29 2 2 4 4 7 7 3 3
2004/09/30 2 2 3 4 6 6 5 5
etc.
Thank you for your help in this matter
Cheers
Rich
A newbie to SQL