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
- BeginnerE-commerceProducts still on the shelf
List every product Northwind can still sell, with price and remaining stock.
- BeginnerE-commerceCustomers in Germany
Find the customers Northwind serves in Germany.
- BeginnerE-commerceFive newest customers
Show the five customers who created accounts most recently.
- BeginnerE-commerceFive most expensive products
Rank the catalog by price and return the five most expensive products.
- BeginnerE-commerceDistinct product categories
List each category Northwind sells, once.
- BeginnerE-commerceProducts with unknown stock
Find products whose stock has not been recorded.
- BeginnerHRHires since 2023
List employees who joined on or after 1 January 2023.
- BeginnerMarketingLeads still marked new
Pull marketing leads that have not been qualified yet.
- BeginnerUniversityComputer science students
List students enrolled in the Computer Science program.
- BeginnerLogisticsShipments still in transit
Show parcels that have left the warehouse and have not been delivered or cancelled.
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