August 9, 2013 at 9:25 am
Hi Team,
am using below select statement, but getting error
SELECT id, name, Count(id) AS T FROM testtest
Error:
Column 'testtest.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Please help
August 9, 2013 at 9:28 am
The error message is pretty clear, you have a column in the select clause that's not included in a group by clause, as it has to be because of the count.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 9, 2013 at 9:30 pm
Minnu (8/9/2013)
Hi Team,am using below select statement, but getting error
SELECT id, name, Count(id) AS T FROM testtest
Error:
Column 'testtest.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Please help
You need to add a GROUP BY for ID and Name.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply