SQL
4 min read
BEGINNER
Column projection
Quick AnswerProjection means choosing which columns or expressions appear in a query result. It does not remove columns from the stored table. Request only the information your task needs.
Core idea
Projection means choosing which columns or expressions appear in a query result. It does not remove columns from the stored table. Request only the information your task needs.
Minimal example
sql
SELECT price_cents, name FROM products ORDER BY id;Expected rows (in order):
text
350 | Notebook150 | Pen2400 | Bag100 | PencilHow it works
The order of the SELECT list determines output column order. SELECT * expands the available columns, which is handy for exploration but can make application output change when the schema changes. Ordinary projection preserves repeated rows; DISTINCT is a separate operation.
Practical example
sql
SELECT * FROM products ORDER BY id;Expected rows (in order):
text
1 | Notebook | 3502 | Pen | 1503 | Bag | 24004 | Pencil | 100Common mistake and practice
Do not assume selecting fewer columns removes duplicates. Write a query returning customer_id from orders; expect 1, 1, 2 in id order.