Sospetto che tu voglia solo qualcosa come: SELECT HOUR(ShoppingDate), COUNT(*) FROM YourTable GROUP BY HOUR(ShoppingDate)