andrzej1_1
andrzej1_1

Reputation: 1193

SQL: Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause

I am getting error:

Column 'movie.title' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

So I used GROUP BY statement, but it does not help.

SQLFiddle: http://www.sqlfiddle.com/#!6/25cab/13

Upvotes: 0

Views: 882

Answers (2)

Nylix
Nylix

Reputation: 108

All items in the SELECT-clause must be in the GROUP BY - clause as well.

An alternative way could be to COUNT the reserve.ID in a preceding query.

If you put only one item from the SELECT clause within GROUP BY it remains unclear, what should happen to the other ones: SUM, MAX, MIN, ??????

Upvotes: 2

Nylix
Nylix

Reputation: 108

The cause for your problem is "Count(reserved.id) AS Expr1". This does not make any sense without a GROUP BY-statement.

Upvotes: 0

Related Questions