Why it happens: the column does not exist
SELECT name, final_price
FROM products;The sample data has price; final_price does not exist.
Check the result with small data
If you need the name final_price as a label, there is no need to invent a new column.
WITH products(name, price) AS (VALUES ('Mouse',20))
SELECT name, price AS final_price FROM products;| name | final_price |
|---|---|
| Mouse | 20 |
The real column is called price and the output alias is final_price. That only solves a naming issue; if you want a calculated amount, you have to define the formula.
Check your understanding: What would you change if final_price included 21 % tax?
Show answer
You would have to calculate it, not just rename it: price * 1.21 AS final_price. An alias names an expression, but it does not perform any calculation.
How to fix it in SQL
SELECT name, price
FROM products;How to check it
Look at the real schema and run a minimal SELECT with the correct column.
How to avoid it next time
Do not create a column to hide a naming or scope error.
Related cases worth checking
| Cause | What to check | Next step |
|---|---|---|
| Misspelt name or a column that does not exist | Compare the SQL with the real table schema. | Fix the identifier, or the migration that should have created or renamed the column. |
| Wrong table or alias | Check which tables appear in FROM/JOIN and which aliases you gave them. | Qualify the column with the correct alias. |
| Output alias used too soon | An alias defined in SELECT is not available in all clauses. | If the problem is in WHERE, use the guide Alias does not work in WHERE. |
| Text written as though it were an identifier | Check text literals and quotes. | For text values, use the proper literal syntax; in the course's portable SQL, that means single quotes. |