You've built a strong foundation with the basics of SQL:
SELECT
WHERE
DISTINCT
ORDER BY
LIMIT
and OFFSET
Now it's time to take a step back, review what you've learned, and apply your knowledge to practical questions — just like you would in real projects.
In this review lesson, you'll revisit core query syntax, analyze real-world questions, and practice combining multiple SQL clauses to answer them. These tasks will strengthen your skills and boost your confidence before we dive into joins and aggregations in upcoming lessons.
Here's the basic format of a flexible SQL query that uses everything you've learned so far:
SELECT column1, column2
FROM table_name
WHERE condition
ORDER BY column1 DESC
LIMIT 5 OFFSET 10;
This single query structure can be shaped to answer a wide range of data questions by combining the different clauses you've mastered.
Remember the execution order:
FROM
- Get data from the tableWHERE
- Filter rows based on conditionsSELECT
- Choose which columns to displayDISTINCT
- Remove duplicate rows (if used)ORDER BY
- Sort the resultsLIMIT/OFFSET
- Limit the number of results returnedLet's switch things up! Instead of movies, you'll now be working with a new dataset featuring some of the world's top universities. This will give you practice applying your SQL skills to different types of data.
The top_universities
table structure:
id | university_name | country | city | student_count | founded_year
---|------------------------|-------------|-----------|---------------|-------------
1 | Harvard University | USA | Cambridge | 21000 | 1636
2 | University of Oxford | UK | Oxford | 24000 | 1096
3 | Stanford University | USA | Stanford | 17000 | 1885
4 | University of Tokyo | Japan | Tokyo | 28000 | 1877
5 | ETH Zurich | Switzerland | Zurich | 23000 | 1855
This table contains information about university names, locations, student populations, and founding years — perfect for practicing your filtering and sorting skills!
As you work through these exercises, watch out for these common mistakes:
🚫 Forgetting SELECT
before FROM
Always start your queries with what you want to retrieve.
-- ❌ Wrong
FROM top_universities WHERE country = 'USA';
-- ✅ Correct
SELECT university_name FROM top_universities WHERE country = 'USA';
🚫 Using =
instead of LIKE
(or vice versa) Remember =
works for exact matches. LIKE
is for patterns (we'll dive deeper in a future lesson).
-- For exact matches
WHERE country = 'USA'
-- For pattern matching (future lesson)
WHERE university_name LIKE '%University%'
🚫 Using ORDER BY
without specifying ASC
or DESC
It defaults to ascending (ASC
), but it's best to be explicit — especially when showing top results.
-- ❌ Unclear intention
ORDER BY student_count
-- ✅ Clear intention
ORDER BY student_count DESC -- Largest first
If you're stuck on a query, try breaking it into steps. Think about:
SELECT
FROM
WHERE
ORDER BY
, LIMIT
, OFFSET
Example thought process: "Find the 3 universities with the most students"
SELECT university_name, student_count
FROM top_universities
ORDER BY student_count DESC
LIMIT 3;
By now, you should feel comfortable with:
SELECT
queries from scratch without hesitationWHERE
💡 Pro Tip: The best way to master SQL is through practice. Don't just complete the exercises — try variations! Change the conditions, sort by different columns, or combine multiple filters. The more you experiment, the more confident you'll become.
In this lesson's practice section, you'll work with the top_universities
table to solidify your understanding of fundamental SQL concepts.
You'll practice:
DISTINCT
to real dataEach exercise is designed to reinforce a key concept while building your confidence with different types of data scenarios. Take your time, experiment with variations, and remember that making mistakes is part of the learning process.
After completing these exercises, you'll be ready to tackle more advanced topics like combining data from multiple tables with JOINs — where SQL really starts to shine and gets closer to real-world database work!
Ready to practice SQL? Try our coding challenges →