SQL practice › SQL errors
SQL errors: what each one means, with a broken query to fix
An SQL error message names the thing the database tripped on, not the mistake behind it. Each page gives the causes in the order worth checking and reproduces the error on a real database in your browser: the query is broken, and you fix it.
Errors
- Ambiguous column nameTwo tables in the query have a column with that name. Say which one you mean with a table name or an alias.
- Column must appear in GROUP BYA selected column is neither grouped nor aggregated. Most databases refuse the query; SQLite runs it and picks a value.
- Aggregate function in WHEREWHERE filters rows before anything is counted or averaged. Use HAVING for a condition on a group, a subquery to compare a row with a total.