This is my query:
SELECT COUNT(*) AS Expr1, name, appointment_date
FROM ReportingTable
GROUP BY name, appointment_date
I want to group the appointment_date column by month as follows:
SELECT COUNT(*) AS Expr1, name, appointment_date
FROM ReportingTable
GROUP BY name, MONTH(appointment_date)
But my query raises the following error:
Column “appointment_date” is invalid in the selected list because it
is not contained in either aggregate function or groupby clause .
Would this work: