I have to assume that one of the columns in vw_B2H_CLIENTS
is the date you are filtering by.
In this case, you could try using DATEPART
in order to group by the month (replacing DATE_COL
by your date column), as so:
SELECT DATEPART(month, DATE_COL) AS Month,
COUNT(*) AS Count
FROM ECMS_BACKUP.dbo.vw_B2H_CLIENTS
WHERE CLT_NBR IN (SELECT CLT_NBR FROM ECMS_BACKUP.dbo.ufn_B2H_Enrolled_Clients_List(@From_DT, @To_DT))
GROUP BY DATEPART(month, DATE_COL)
Also note that you may have an error in ufn_B2H_Enrolled_Clients_List
as you have @From_DT
as the parameter twice (you may want @To_DT
).
This would give you output like this:
Month Count
7 251
8 255
9 250
10 245