SQL Query to return records grouped by Week, Month, and Year. Weeks with no records should return 0
问题 Given the following data: ID CreatedDate ID1 2014-06-04 01:40:56.880 ID8 2014-06-05 00:27:02.403 ID6 2014-06-04 01:51:47.060 ID7 2014-06-05 00:25:35.187 ID4 2014-06-04 01:48:44.157 ID10 2014-06-05 00:28:33.993 ID43 2014-06-16 05:17:18.803 ID72 2014-06-20 04:00:07.733 . . . Etc. I need to write a query that will group records by week, month, and year. A count of the number of records that were created in a particular week needs to be returned. The output should be as follows: Week Month Year