I'm using SQL SERVER 2014
I nead Ignore this error . GROUP BY with Aggregate Functions SLQSTAT = 42000
My problem is while executing this query
select empId, empName, empstate, sum(empsalary)
from emp
group by
empId, empName ;
Result :
COLUMN empId . is invalid in the select list because it is not contained in either an Aggregate Functions or the GROUP BY clause .
this an simple example in my select . I Nead To ignore adding [empstate] to the GROUP BY
I have thousands data window nead update groups
how can do this ?
When you modify the SQL to add the empstate column to the SELECT clause, you have two possible options,
1. Use an aggregate function with the empstate column, for example MIN(empstate) or MAX(empstate), if appropriate. Including empstate in an aggregate function negates the need to include empstate in the GROUP BY clause. Or...
2. Include empstate in the GROUP BY clause.
This is how SQL (not just SQL Server, but SQL in general) works. This is a SQL syntax rule...you cannot ignore it.