Skip to content
QueryLab

SQL practice for beginners

The first skill is choosing rows and columns on purpose. These exercises stay on one table so the question is the filter, the sort, or the unknown value, not a join.

Read the column list before you write SELECT

Every beginner exercise names the output columns and the sort. If the request says stock greater than zero, a NULL stock is not greater than zero. If it says the five newest customers, LIMIT without ORDER BY is unfinished.

ISO dates compare as text

These datasets store dates as YYYY-MM-DD. A string comparison with that format is chronological, so hire_date >= '2023-01-01' means what it looks like.

Example

SELECT name, email, city
FROM customers
WHERE country = 'Germany'
ORDER BY name;

Filter on the column the question names. City is not a stand-in for country.

Practice

Common mistakes

  • Writing WHERE stock = NULL instead of IS NULL.
  • Applying LIMIT before deciding the order.
  • Selecting every column when the consumer asked for three.
  • Using DISTINCT when the duplicate rows are separate business events.

FAQ

Should beginners learn joins immediately?
Learn a reliable WHERE and ORDER BY first. Joins are next, and they are easier when you can already predict which rows a filter keeps.
Why do some products disappear when I filter stock > 0?
Because unknown stock is not greater than zero, and zero is not greater than zero. That is the behavior you want for a shelf list.

Related practice

Start solving SQL challenges today.

Open Products still on the shelf and check the result in the browser. An account is optional.

Start practicing free