SQL puzzles and challenges
You solve tough data questions taken from real work with a single SQL query and test your solution for correctness and speed.
Level 301 · 16 lessons · 15 practice labs
Lessons
Warm-up
- The second-highest salary
- Consecutive login days
- Duplicate email addresses
- Missing numbers
- Short task: a mixed set of four questions
Time and order
- Overlapping bookings
- Calculating the median
- The longest streak
- An account balance history
- Gaps in shift coverage
- Short task: time series puzzles
Structure and hierarchy
- Bill of materials cost
- The shortest path through a table of routes
- Relational division: those who took them all
- A cross-tab report
- Capstone: ten puzzles against the clock
Practice labs
- Find the third-highest salary: Write one query returning the third-highest salary, counting equal salaries correctly.
- Find missing invoice numbers: List the gaps in invoice numbers that should be sequential as ranges.
- Match emails written differently: Normalise and group email addresses that repeat with case, space and dot differences.
- Find overlapping room bookings: List pairs of Yakamoz Otel bookings for the same room with overlapping dates.
- Find gaps in shift coverage: Find the time ranges when no nurse is on duty in Ardıç Sağlık's emergency room.
- Merge overlapping intervals: Merge a machine's overlapping maintenance records and compute total downtime in one query.
- Calculate the median order value: Write a median query without a built-in function that works for both odd and even row counts.
- Find the longest workout streak: Find each Ilgın Spor member's longest run of consecutive gym days.
- Build a daily balance history from movements: From account records that contain only days with movements, produce a closing balance for every day.
- Expand a product's parts list: List every level of sub-parts and quantities for one of Kestane Mobilya's cabinets.
- Calculate cost from a parts tree: Multiply nested part quantities to calculate a product's total material cost.
- Find the cheapest connecting flight: Find the cheapest route with at most two connections between two cities in Pusula Turizm's routes table.
- Find who completed every mandatory course: List employees who completed every mandatory training using GROUP BY and a count.
- Assign tasks by matching skills: Use relational division to find employees who hold every skill a project requires.
- A ten-question set against the clock: Solve ten puzzles on ranking, ranges, streaks and cross-tabs on a mixed dataset within 25 minutes.
About this course
You solve tough data questions taken from real work with a single SQL query and test your solution for correctness and speed.
What you will learn
- Warm-up
- Time and order
- Structure and hierarchy
Prerequisites
You should be comfortable with the level 101 and 201 topics of the same path.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 301; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.