Skip to main content
eLearner.app

End of the SQL Course

Summary and final challenge

Congratulations: you have completed the 8 modules of the SQL Course — from the first SELECT queries to WITH RECURSIVE, window functions, and transactions. Below is the map of everything you now master and a final challenge that combines key parts of them. If you solve it, you are ready to write SQL in any real project.

01 · Basic SELECT

  • SELECT … FROM
  • WHERE
  • ORDER BY (ASC/DESC)

02 · More Powerful SELECT

  • LIMIT
  • DISTINCT
  • aliases with AS
  • COUNT, AVG, SUM, MAX, MIN

03 · JOIN and GROUP BY

  • INNER JOIN
  • LEFT JOIN
  • GROUP BY
  • HAVING

04 · Practical SQL

  • IN / BETWEEN
  • IS NULL / COALESCE
  • CASE WHEN
  • subqueries

05 · Advanced JOINs

  • multi-JOIN
  • RIGHT/FULL OUTER
  • self-join
  • UNION / INTERSECT / EXCEPT

06 · Functions

  • string
  • numeric
  • date/time
  • CAST and conversions

07 · Analytics

  • window functions
  • LAG / LEAD
  • CTE (WITH)
  • WITH RECURSIVE

08 · Writing Data

  • INSERT
  • UPDATE / DELETE
  • CREATE / ALTER
  • BEGIN / COMMIT / ROLLBACK

The final challenge

Four techniques in a single query: a CTE that aggregates orders per customer, two JOINs to build it, a window function to assign rank, and LIMIT to return the podium. No new lesson: just combine what you have learned from Module 1 to Module 8.

Exercise#sql.boss.e1
Attempts: 0Loading…

Find the top 3 customers who have spent the most. Use a CTE to calculate total spending per customer (sum of quantity * unit_price on all order_items), then assign each a rank with RANK() OVER (ORDER BY ... DESC) and return first_name, last_name, total, and rank, ordered from highest to lowest. Limit to 3 rows.

Loading editor…
Show hint

In the CTE: JOIN orders on o.customer_id = c.id, JOIN order_items on oi.order_id = o.id, sum quantity * unit_price. In the outer query: RANK() OVER (ORDER BY total DESC) and LIMIT 3.

Solution available after 3 attempts

Printable Cheatsheet

A page with all the essential SQL syntax, ready to keep handy while you write your queries.

Open the cheatsheet

What now?

The best way to consolidate is free practice. Open the Playground, load one of the datasets, and try to answer questions that come to mind: who earns above the average in the world?, how many employees per city?, which projects have at least two people assigned? Nothing is better to turn theory into instinct.