Description:
No ChatGPT. No Claude. You've got 10 seconds. Postgres rejects this query. Why?
SELECT name,
price * qty AS total
FROM order_items
WHERE total > 100;
ERROR: column "total" does not exist
Why: WHERE runs before SELECT. The alias total is created in SELECT, so WHERE can't see it yet.
Fix: repeat the math in WHERE.
WHERE price * qty > 100
We ran it in Postgres: the first version errors, the fixed one returns 2 rows. SQLite and DuckDB accept the alias, so it can pass on your laptop and break in production.
Or ask in plain English. AI2sql writes the SQL for PostgreSQL, MySQL and SQL Server.
Fixed it in 10? Tell me your time in the comments.
#sql #postgresql #shorts
Share this link via
Or copy link























