I am using the following code to generate the number of different ethnic groups that we saw in a particular month.
SELECT
COUNT(a.[_PatientId]) 'Quits set',
a.Ethnicity
FROM (SELECT
[_PatientId],
SUBSTRING(CAST([_Ethnicity] AS VARCHAR),1,50) AS 'Ethnicity'
FROM [Test].[dbo].[smoking_data$]
WHERE [_Quit_Date] BETWEEN '2015-10-01' AND '2015-10-31'
) a
GROUP BY a.Ethnicity
which gives this result:
Quits set Ethnicity
129 A - White British
1 B - White Irish
6 C - White other
1 F - Mixed White and Asian
2 G - Mixed Other Background
1 L - Asian/Asian British Other
1 S - Any Other Ethnic Group
3 Unknown
1 Z - Declined
Is there any way for it to have the ethnicity as it is now, but a separate column of numbers for each month, rather than having to do it one month at a time?