Any help with adding the count funtion into the below query, counting on the id?
SELECT DISTINCT TOP 10 left(convert(varchar,B.CreatedDate,112),6) as CreatedDate_YYYYMM , B.id
FROM tbl B
Result set:
CreatedDate_YYYYMM id
201201 4
201201 1
201202 2
201203 3
201203 5
I would like to see a count of id per CreatedDate_YYYYMM:
CreatedDate_YYYYMM Count
201201 2
201202 1
201203 2