I have a list of roughly 3000 rows. Each row has a different end time. see below
Fund name | Fund ID | RedeemTime | PurchaseTime | LatestTime |
__________ _________ ____________ ____________ | ___________ |
Title1 | IDnumber | 4:00:00 | 14:30:00 | 14:30:00 |
Title2 | IDnumber2 | 13:30:00 | 12:00:00 | 13:30:00 |
Title3 | IDnumber3 | 10:00:00 | 14:00:00 | 14:00:00 |
Title4 | IDnumber4 | 10:00:00 | 10:30:00 | 10:30:00 |
I am currently using a case statement for the 5th column to find the later of the two times.
I need to take the 5th column and provide a count of what happens each hour. For example on the table above the results would be
Hour | Count
_________ _______
10:00:00 | 1
13:00:00 | 1
14:00:00 | 2
You could “normalize” the two times in a subquery. You can generate a list of hours using a CTE. For example, for all hours in August 2012:
If you don’t have a table filled with hours, there are ways to generate it. They all depend on your database. So if you’d like help with that, post which database you are using.