I need to create a pivot table where going down the left side it will show 7 days of data from the date I have picked, and then on top will be 4 different times, and the need to count the records.
So basically on 1-14-09 there are 5 appointments at 08:15 AM, 5 appointments at 11:00 AM and so on.
I have never created a pivot table in SQL before, so this is very new to me.
SELECT COUNT(dtPartyTime) AS [8:45]
WHERE (dtPartyTime = '08:45 AM') AND (dtDate BETWEEN @dtDate AND dateadd(day, 7, @dtDate))
This is the code I am using to just count values for the specific times, just not sure how to pivot this out in order to get the same information just showing each of the 7 days, and then totalling each time at the bottom.
Any help would be appreciated.