SQL Server error: invalid column selection list, because it is not included in the aggregate function or the GROUP BY clause

Aggregation function: return a single value aggregation function is to calculate a set of values.

include:

COUNT (statistical function);
the COUNT_BIG (statistical function);
the SUM (sum function);
the AVG (averaging function);
MAX (maximum function);
MIN (minimum value function);
STDEV (standard deviation value function);
on VAR (variance function);
hAVING (hAVING clause is used in the query with the gROUP BY clause, the WHERE clause is used to filter the data in each row (in the group becomes a certain part of before), while hAVING clause aggregate values for screening packet)

-----------------------------------------------------------------

Title wrong solution: When specifying [GROUP BY], select all of the statements of non-aggregate functions listed should match the GROUP BY list, or the GROUP BY list must select statement with all non-aggregate function column exact match.

Such as:

select id,x,y,max(time)
from[Test1].[dbo].[seven]
group by id

The title of the error will occur. Can be changed to:

select id,x,y,max(time)
from[Test1].[dbo].[seven]
group by id,x,y

 

Reference from:

https://www.cnblogs.com/limeiky/p/5499163.html

https://www.cnblogs.com/Brambling/p/6711937.html

Guess you like

Origin www.cnblogs.com/PER10/p/11279146.html