Skip to content
When SQL won't run

SQL error messages explained

Paste the error your database gave you, or scan the list below. Each page shows the failing query, runs it in your browser, and explains what the database is telling you.

Other errors you will meet

These come up often enough to cover here, even without a dedicated page yet.

Referenced column ... not found

The column name is misspelled, lives in a different table, or needs a table alias. Check it against the schema, and qualify it (c.customer_id) when more than one table is in play.

Syntax error near ...

Something is malformed at that spot. The usual culprits: a missing comma between selected columns, an unclosed quote or parenthesis, or a misspelled keyword. The error points to where parsing broke, which is often right after the real mistake.

No function matches the given name and argument types

A type mismatch, often from comparing text to a number or passing a string where a date is expected. Cast explicitly withCAST(x AS INTEGER) or fix the literal's quotes.

Conversion error / could not convert

A value could not be coerced to the needed type, for example the text'N/A' in a numeric column. Filter or clean the bad values first, or guard withTRY_CAST (DuckDB), which returns NULL instead of failing.

If the query runs without complaint and comes back empty, there is nothing here to decode: it succeeded. Readwhy a query runs but returns no rows instead.

When you get stuck on any of these, rebuild the query in small steps. Start withSELECT * FROM table, add one join, then one filter, checking the result after each change.