Random SQL exercises: a new task at the push of a button
Fixed exercises can be memorized. Here every task is built fresh: other values, other thresholds, other columns. 33 topics from levels 1 to 5 of the course, each as often as you like.
In short: pick a topic, click New exercise, write the query, check it. As with every exercise, the result is checked, also on hidden data. Random exercises are part of Premium, like the "More exercises" button in the lessons.
How the random exercises work
Every topic has a task builder. With each click it draws new values: another category, another city, another threshold, another sort order. From these it builds the task, the model answer and a hidden variant of the data. You only see the task and the tables; the answer stays on the server.
You write the query, run it and check it, just like in the SQL practice exercises. If the result is right, your query runs again on the variant, where a hard-coded value shows up. If you are stuck, the hint and the solution help.
Solved random exercises earn points, half as many as a fixed exercise on the same topic. They shrink per topic and day, so repeating an easy task does not count more than a new topic.
The topics
The tasks belong to the lessons of levels 1 to 5. If a topic is new to you, read the lesson first.
Level 1: Getting started
- Basics: tables, rows, columns
- SELECT: query columns
- WHERE: filter rows
- AND, OR, NOT
- IN and BETWEEN
- LIKE: pattern matching
- NULL and COALESCE
- ORDER BY and LIMIT
- DISTINCT: drop duplicates
- Calculations and column aliases
Level 2: Summarizing data
- COUNT: count rows
- SUM, AVG, MIN, MAX
- GROUP BY: summarize groups
- HAVING: filter groups
- CASE WHEN: conditional logic
- String functions
- Dates and times
Level 3: Joining tables
- INNER JOIN: joining tables
- LEFT JOIN
- Joining multiple tables
- Self join
- UNION
- Subqueries
- EXISTS and NOT EXISTS
Level 4: Changing data and building tables
Level 5: Advanced queries
- WITH (CTE)
- Window functions: ROW_NUMBER, RANK
- Running totals and shares
- LAG and LEAD
- Pivot with CASE WHEN
- Finding duplicates
When random exercises help
- Before a test or interview: "All topics mixed" asks across the board, like an SQL test.
- After a lesson: three or four new tasks on the same topic show whether it really sticks.
- For review: a topic from a few weeks ago with new values is the best check that you still know it.
Without Premium you can practise for free with every exercise in level 1, the first exercise of every other lesson and the SQL online editor for free-form queries.
Frequently asked questions
How many random exercises are there?
As many as you like. Every task is built when you click. Some combinations come back eventually, but the values change with every click.
Are the random exercises free?
No, they are part of Premium. Free are level 1 of the course with its project, the first exercise of every lesson and the online editor.
Why are some lessons missing?
Random exercises exist wherever the result can be built and checked automatically and reliably: queries, JOINs, subqueries, window functions and changes with INSERT, UPDATE and DELETE. Creating and altering tables, keys, views, transactions and the level 6 topics are practised with the fixed exercises in the lessons and the projects at the end of each level.
Do random exercises count for the learning path?
The ticks in the learning path come from a lesson's fixed exercises. Random exercises earn extra points.