Unanswered: Stored Procedure - Field not in aggregate function or group by
Hope someone can help me work out the best solution for this stored procedure query.
I'm getting the following error:
Column 'dbo.Applicants.submitted' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
Here is my select query:
SELECT DISTINCT DATENAME(MONTH, submitted) AS mon, MAX(submitted) AS SubmitDate
WHERE ((CASE WHEN MONTH(submitted) > 8 THEN YEAR(submitted) + 1 ELSE YEAR(submitted) END) = @AcYr)
ORDER BY SubmitDate
The submitted field is a date field.
I don't want to add the submitted field to Group By as I want to group by month not date.