I have a T-SQL query as below which queries a table holding the search data and gets the search hour and count of the rows for that search hour.
SELECT DATEPART(HOUR, aps.CreatedOn) AS SearchHour, COUNT(*) AS ItemCOUNT
FROM ASearches aps
GROUP BY DATEPART(HOUR, aps.CreatedOn)
ORDER BY SearchHour;
As you can see, this does’t produce a great result. However, I know that if I use a Pivot table for this and have the hours as column names, that would be better. I tried but I have been failing so far.
Any idea how?
Something like this: