SQL, Actually

A SQL course · PostgreSQL · runs in your browser

Learn SQL by doing the job.

You’ve just joined ShopKart, an Indian online store, as its first data analyst. Every lesson starts with a message from someone on the team, and ends with you answering it on real data.

No install and no sign-up to start. The query on this page runs in real Postgres — edit it and press Run.

Farhan· Finance

Which cities bring in the most revenue? Top five, please.

answer.sqlReal Postgres · runs in your browser
SELECT c.city, COUNT(*) AS orders,
       SUM(p.amount) AS revenue
FROM orders o
JOIN customers c ON c.customer_id = o.customer_id
JOIN payments p ON p.order_id = o.order_id
WHERE p.status = 'success'
GROUP BY c.city
ORDER BY revenue DESC
LIMIT 5;
5 rows · press Run to try it yourself
cityordersrevenue
Mumbai3422331136.00
Delhi3752228391.00
Pune3021875883.00
Bengaluru3171714172.00
Chennai2531589936.00
78
short lessons
2.5 hrs
of video, about 2 minutes each
8
tables, one company
45,464
rows of real-looking data
How a lesson works

A question first. The syntax second.

Nobody learns LEFT JOIN for fun. You learn it because Meera needs a list by lunchtime. This is lesson 5.4, start to finish.

  1. 01 — the ask
    Meera· Head of Growth

    Which customers signed up but never ordered? I want to send them a coupon.

    Someone on the team needs an answer. That is the whole reason for the lesson.

  2. 02 — the videoA frame from the LEFT JOIN video1:44

    A short, hand-drawn explanation that follows a few real rows through the query.

  3. 03 — your turn
    SELECT c.customer_id, c.first_name, c.city
    FROM customers c
    LEFT JOIN orders o ON o.customer_id = c.customer_id
    WHERE o.order_id IS NULL;

    The lesson’s query, ready to run and change. It is a real database, so you can break it.

  4. 04 — the trap

    COUNT(*) gives 1 for customers with zero orders. Use COUNT(o.order_id).

    Every lesson names the one mistake nearly everyone makes with that topic.

The people you’ll work for

Four colleagues. They all want something.

  • Meera

    Head of Growth

    “Which cities are our customers in? Just the list, no repeats. And the 10 newest signups.”

    Asks about customers, signups, retention, funnels.

  • Arjun

    Operations lead

    “Can you send me everything we sell? Just the full product list.”

    Asks about orders, deliveries, stock, returns.

  • Farhan

    Finance

    “What's our margin on each product — in rupees and in percent?”

    Asks about revenue, margins, payments, refunds.

  • Kavya

    Senior engineer

    “Why is 10 less than 9 in this report?”

    Asks about schema design, performance, slow queries.

The dataset

One database, from the first lesson to the last.

ShopKart’s data covers two and a half years of orders, 1 January 2024 to 30 June 2026. You will know it the way you would know a real company’s database.

It is deliberately imperfect: missing phone numbers, duplicate emails that differ by a capital letter, and a city spelt both Bangalore and Bengaluru. Cleaning that up is part of the job, and part of the course.

Open the playground
customers608 rowsEveryone who signed up. A few duplicate emails and two spellings of Bengaluru — on purpose.
categories25 rowsA three-level tree: Electronics › Mobiles › Smartphones.
products136 rowsWhat ShopKart sells, with price, cost price and stock.
orders3,319 rowsOne row per order: who, when, status, where it shipped.
order_items6,364 rowsThe lines of each order — the bridge between orders and products.
payments3,397 rowsPayment attempts: method, amount, success / failed / refunded.
reviews1,724 rowsStar ratings and review text for products.
events29,891 rowsWebsite activity: page views, product views, carts, checkouts, purchases.
The course map

From your first SELECT to a mock interview.

13 modules. Each one ends with something you can actually do at work.

Foundations

0Welcome3 lessons · 6 min

Understand what a database is and why SQL matters, and run your first query within ten minutes.

  1. 0.1Why SQL still runs the worldFree2:00
  2. 0.2Tables, rows and columnsFree2:05
  3. 0.3Meet ShopKartFree2:23
1First Queries5 lessons · 9 min

Read any single table: choose columns, calculate new ones, sort, and limit.

  1. 1.1Your first queryFree1:38
  2. 1.2Picking columns & aliasesFree1:48
  3. 1.3Calculated columnsFree1:54
  4. 1.4Sorting with ORDER BYFree1:30
  5. 1.5LIMIT, OFFSET & DISTINCTFree1:48
2Filtering6 lessons · 11 min

Return exactly the rows you want, and understand how NULL breaks intuition.

  1. 2.1WHERE & comparisonsFree1:38
  2. 2.2AND, OR, NOT2:03
  3. 2.3IN & BETWEEN2:06
  4. 2.4Pattern matching with LIKE1:50
  5. 2.5NULL — the value that isn't there2:00
  6. 2.6Filtering by date & time1:47
3Functions6 lessons · 11 min

Transform values: clean text, round numbers, work with dates, and write if/else logic.

  1. 3.1Text functionsFree1:51
  2. 3.2Number functions1:54
  3. 3.3Working with dates1:49
  4. 3.4CASE WHEN1:47
  5. 3.5COALESCE & NULLIF1:40
  6. 3.6Data types & CAST1:38
4Aggregation6 lessons · 12 min

Summarise data: totals, averages, counts per group. This is the first module where SQL feels like analysis.

  1. 4.1Aggregate functionsFree1:51
  2. 4.2GROUP BY1:45
  3. 4.3Grouping by several columns1:36
  4. 4.4HAVING vs WHERE1:41
  5. 4.5The order SQL runs3:10
  6. 4.6Conditional aggregation1:48

Core

5Joins8 lessons · 16 min

Combine tables confidently, and know exactly how many rows a join will return before running it.

  1. 5.1Why data lives in many tablesFree1:35
  2. 5.2Primary & foreign keys1:42
  3. 5.3INNER JOIN3:41
  4. 5.4LEFT JOIN1:44
  5. 5.5RIGHT & FULL OUTER JOIN1:44
  6. 5.6Joining three or more tables1:41
  7. 5.7Self join & CROSS JOIN1:42
  8. 5.8Join traps1:50
6Subqueries & CTEs6 lessons · 11 min

Break hard questions into steps, using queries inside queries and readable WITH blocks.

  1. 6.1Subqueries in WHEREFree1:49
  2. 6.2IN & NOT IN subqueries2:05
  3. 6.3EXISTS & NOT EXISTS1:51
  4. 6.4Correlated subqueries1:52
  5. 6.5CTEs — WITH1:42
  6. 6.6Recursive CTEs1:55
7Set Operations2 lessons · 4 min

Stack and compare query results vertically.

  1. 7.1UNION vs UNION ALLFree1:49
  2. 7.2INTERSECT & EXCEPT1:45
8Window Functions8 lessons · 14 min

Calculate across related rows without collapsing them: rankings, running totals, and comparisons with the previous row.

  1. 8.1What is a window?Free1:36
  2. 8.2PARTITION BY1:29
  3. 8.3ROW_NUMBER, RANK, DENSE_RANK1:31
  4. 8.4Top-N per group1:31
  5. 8.5Running totals1:51
  6. 8.6Frames: moving averages2:05
  7. 8.7LAG & LEAD1:39
  8. 8.8NTILE, FIRST_VALUE, LAST_VALUE2:01

Advanced

9Building Databases7 lessons · 14 min

Go from reading data to designing and changing it: tables, constraints, inserts, updates, and good schema design.

  1. 9.1Designing a schemaFree2:17
  2. 9.2CREATE TABLE & data types2:03
  3. 9.3Constraints2:10
  4. 9.4INSERT1:43
  5. 9.5UPDATE & DELETE2:00
  6. 9.6ALTER, DROP, TRUNCATE2:01
  7. 9.7Normalization2:13
10Performance & Reliability6 lessons · 12 min

Understand what the database does with your query, make slow queries fast, and keep data consistent when things fail.

  1. 10.1EXPLAINFree2:06
  2. 10.2Indexes1:59
  3. 10.3When indexes don't help1:53
  4. 10.4Transactions1:51
  5. 10.5ACID & concurrency2:00
  6. 10.6Views & materialized views1:56
11Real-World Analytics7 lessons · 14 min

Combine everything into the analyses companies actually pay for: growth, funnels, cohorts, segmentation.

  1. 11.1Pivoting dataFree1:46
  2. 11.2Date spines & filling gaps1:55
  3. 11.3Growth: MoM & YoY2:13
  4. 11.4Conversion funnels2:02
  5. 11.5Cohort retention2:06
  6. 11.6RFM segmentation1:49
  7. 11.7Data quality & deduplication2:00
Daily practice · free for everyone

One question a day. Keep the streak.

Every day the team sends one new question, at your level. You answer it on the real database and it is checked against the real result, not a multiple-choice guess.

Solve it, or finish a lesson, and the day counts towards your streak.

Try today’s question
Arjun· Operations lead

Which products cost more than ₹10,000? Most expensive first.

  1. M
  2. T
  3. W
  4. T
  5. F
  6. S
  7. S

5 days and counting

Pricing

Start free. Pay when you’re sure.

The first two modules, the first lesson of every other module and daily practice cost nothing.

Free

₹0

Start here. No card needed.

  • 19 lessons: Modules 0 and 1, and the first lesson of every module
  • Daily practice question, every day
  • Streaks and saved progress
  • The full SQL playground
Start learning

best value — save 69%

Yearly

₹2,999/ year

Works out to ₹250 a month.

  • All 78 lessons, including the 59 not in the free tier
  • Window functions, performance, analytics and interview prep
  • A certificate of completion anyone can verify
  • Everything in Free

Monthly

₹799/ month

Cancel whenever you like.

  • All 78 lessons
  • Same access as yearly, billed each month
  • Certificate of completion
  • Everything in Free

Payments are handled by Dodo Payments. Taxes are added at checkout where they apply. You can cancel from your account page at any time.

day one

Your first message from the team is waiting.

Start lesson 0.1