Chapter 1 · 6 min
Selecting columns
Every SQL interview starts the same way: can you get the right rows out of a table without
dragging the whole table along? The SELECT clause names the columns you want, and FROM names
where they come from.
SELECT order_id, customer_id, order_date
FROM orders
LIMIT 10;
Three habits separate a query that works from one an interviewer trusts:
- Name columns explicitly.
SELECT *is convenient while exploring, but it couples your query to the table’s current shape and hides what you actually needed. - Bound the output while you explore.
LIMITkeeps a first look cheap. It is not a filter — it does not change which rows qualify, only how many come back. - Read the schema before you write. Column names, types, and nullability decide what the query can even express. Guessing at them is the most common way a correct idea produces an incorrect query.
A column can also be renamed in the output with AS. That matters in interviews more than in
production: the question usually specifies the exact column names it expects back, and a grader —
human or automated — will compare against those names.