mysql - Error: column is invalid because it is not contained in either an aggregate function or the GROUP BY -
mysql - Error: column is invalid because it is not contained in either an aggregate function or the GROUP BY -
i have such code, works fine:
select count (cast(faculty nvarchar(max))) num pupil grouping cast(faculty nvarchar(max))
faculty
text. need count number of faculty in column, tried code, give error: column 'student.faculty' invalid in select list because not contained in either aggregate function or grouping clause.
select faculty, count (cast(faculty nvarchar(max))) num pupil grouping cast(faculty nvarchar(max))
i cant understand, problem, because same method works fine numbers. illustration one:
select id, count(id) pupil grouping id
what doing wrong?
you error because don't grouping same select. cast(faculty nvarchar(max))
not equal faculty
. why not use:
select faculty, count (*) num pupil grouping faculty
mysql sql oracle tsql group-by
Comments
Post a Comment