[Resolved] SELECT statement

Hi,

I have a table as shown

ID             System Time
34             2009-01-31 14:07:40.263
11             2009-01-31 19:54:38.460
16             2009-02-01 08:58:00.237
10             2009-02-01 15:02:55.757
21             2009-02-01 20:53:33.720
25             2010-10-30 17:16:16.130
109           2010-10-27 17:38:09.380
561           2011-09-31 00:06:22.317

Results expected:

Count                 Month                 Year
2                         01                       2009
3                         02                       2009
2                         10                       2010
1                          09                      2011

Please note, count = SUM of the IDs in that month, Month & Year extracted from System Time. Also, this is just a sample the statement will be executed against millions of records, therefore, expecting count for every calendar month and year.

Thank you in advance

Please paste your query so far.

Select SystemTime
, YEAR (SystemTime) AS Year
, MONTH (SystemTime) AS Month
From Db.Test.TblTest

This picks the month and the year. I need the count now...

add:

count(id) over(partition by month(systemtime), year(systemtime)) as id_count

Thank you - gbritton

Worked perfectly. Much appreciated...

np, please mark the thread as solved if you get a chance!