13 modules · 78 lessons · 2.5 hours of video
The course
Work through it in order. Each lesson is one question from the ShopKart team, a short video, and a query to run yourself.
Your progress on this device
0 of 78 lessons done
Foundations
Welcome
Understand what a database is and why SQL matters, and run your first query within ten minutes.
3 lessons · 6 min
First Queries
Read any single table: choose columns, calculate new ones, sort, and limit.
5 lessons · 9 min
- 1.1Your first queryFree“Can you send me everything we sell? Just the full product list.”1:38
- 1.2Picking columns & aliasesFree“Too much! I only need name, brand and price. And can the price column say price in rupees?”1:48
- 1.3Calculated columnsFree“What's our margin on each product — in rupees and in percent?”1:54
- 1.4Sorting with ORDER BYFree“Which products are the most expensive? Top of the list, please.”1:30
- 1.5LIMIT, OFFSET & DISTINCTFree“Which cities are our customers in? Just the list, no repeats. And the 10 newest signups.”1:48
Mini project The catalog report
Filtering
Return exactly the rows you want, and understand how NULL breaks intuition.
6 lessons · 11 min
- 2.1WHERE & comparisonsFree“Which products are out of stock right now?”1:38
- 2.2AND, OR, NOT“Prime members in Mumbai or Pune. I want to invite them to an event.”2:03
- 2.3IN & BETWEEN“Orders shipped to our 6 metro cities during the Diwali sale — 12 to 22 October. How many?”2:06
- 2.4Pattern matching with LIKE“Can you find every product that mentions "wireless" in its name? It's for a gadgets promo.”1:50
- 2.5NULL — the value that isn't there“How many customers haven't given us a phone number? Planning an SMS campaign.”2:00
- 2.6Filtering by date & time“Closing the books for May — can you pull every order from May?”1:47
Mini project The fraud desk
Functions
Transform values: clean text, round numbers, work with dates, and write if/else logic.
6 lessons · 11 min
- 3.1Text functionsFree“The customer list is a mess — emails in random CAPS, extra spaces at the front. Can you clean it for the newsletter?”1:51
- 3.2Number functions“Margins with one decimal place, and GST prices rounded to the rupee, please.”1:54
- 3.3Working with dates“Which month do people sign up most? And how long do deliveries take?”1:49
- 3.4CASE WHEN“Can you tag every product with a price tier — Budget, Mid-range or Premium?”1:47
- 3.5COALESCE & NULLIF“Blank phone numbers look broken in the call-centre export. Can it say "Not provided" instead?”1:40
- 3.6Data types & CAST“Why is 10 less than 9 in this report?”1:38
Mini project Clean the customer list
Aggregation
Summarise data: totals, averages, counts per group. This is the first module where SQL feels like analysis.
6 lessons · 12 min
- 4.1Aggregate functionsFree“What's our total revenue, and what's the average order value?”1:51
- 4.2GROUP BY“Total revenue is great — but I need it month by month. Did the Diwali sale actually help?”1:45
- 4.3Grouping by several columns“Show me orders by city AND status — I want to see where the cancellations happen.”1:36
- 4.4HAVING vs WHERE“Planning pop-up events — which cities have more than 50 customers?”1:41
- 4.5The order SQL runs“Why does WHERE say my column <i>margin</i> doesn't exist? ORDER BY margin works fine. Is Postgres broken?”3:10
- 4.6Conditional aggregation“One row per month: total orders, cancelled orders, and the cancellation rate — side by side.”1:48
Mini project The monthly business review
Core
Joins
Combine tables confidently, and know exactly how many rows a join will return before running it.
8 lessons · 16 min
- 5.1Why data lives in many tablesFree“Why can't the orders table just include the customer's name and city? Wouldn't one big table be simpler?”1:35
- 5.2Primary & foreign keys“Before you join anything — make sure you know how the tables connect.”1:42
- 5.3INNER JOIN“For each order, I need the customer's name next to it.”3:41
- 5.4LEFT JOIN“Which customers signed up but never ordered? I want to send them a coupon.”1:44
- 5.5RIGHT & FULL OUTER JOIN“Reconciliation time: every order should have a payment, every payment an order. Anything without a match?”1:44
- 5.6Joining three or more tables“Revenue by category, please — smartphones vs earbuds vs kitchen stuff.”1:41
- 5.7Self join & CROSS JOIN“Who referred whom? I want to reward our top referrers.”1:42
- 5.8Join traps“Your revenue number is higher than what the bank says.”1:50
Mini project The customer 360
Subqueries & CTEs
Break hard questions into steps, using queries inside queries and readable WITH blocks.
6 lessons · 11 min
- 6.1Subqueries in WHEREFree“Which products are priced above our average price?”1:49
- 6.2IN & NOT IN subqueries“Gadgets newsletter: which customers have bought anything from Electronics?”2:05
- 6.3EXISTS & NOT EXISTS“Which products do we stock that have never had a single order?”1:51
- 6.4Correlated subqueries“Is each product priced above the average of its OWN category? Earbuds vs phones isn't fair.”1:52
- 6.5CTEs — WITH“Which cities have the most loyal customers? Average orders per customer, per city.”1:42
- 6.6Recursive CTEs“Need the full category path for breadcrumbs — like "Electronics › Mobiles › Smartphones".”1:55
Mini project The product performance audit
Set Operations
Stack and compare query results vertically.
2 lessons · 4 min
- 7.1UNION vs UNION ALLFree“One activity timeline for a customer — every order and every review, in a single list, by date.”1:49
- 7.2INTERSECT & EXCEPT“Who ordered in 2025 but hasn't ordered at all in 2026? Who did we lose?”1:45
Mini project Who did we lose?
Window Functions
Calculate across related rows without collapsing them: rankings, running totals, and comparisons with the previous row.
8 lessons · 14 min
- 8.1What is a window?Free“Show each payment right next to the overall average — I want to spot the unusually big ones.”1:36
- 8.2PARTITION BY“Each product's price vs its OWN category's average — side by side, please.”1:29
- 8.3ROW_NUMBER, RANK, DENSE_RANK“Can you rank all our products by price? Hmm — what happens with ties?”1:31
- 8.4Top-N per group“For the homepage: the top 3 bestsellers in EACH category, please.”1:31
- 8.5Running totals“For the investor update: cumulative revenue by month. When did we cross ₹1 crore?”1:51
- 8.6Frames: moving averages“Daily orders are way too noisy to read. Can I get a 7-day moving average?”2:05
- 8.7LAG & LEAD“Month-over-month revenue change for 2025 — in rupees and in percent, please.”1:39
- 8.8NTILE, FIRST_VALUE, LAST_VALUE“Split customers into 4 spending tiers for the loyalty programme. And each customer's first and latest order?”2:01
Mini project Leaderboards
Advanced
Building Databases
Go from reading data to designing and changing it: tables, constraints, inserts, updates, and good schema design.
7 lessons · 14 min
- 9.1Designing a schemaFree“We're launching a seller marketplace. Can you sketch the tables before I build them?”2:17
- 9.2CREATE TABLE & data types“Great design. Now write the DDL for sellers?”2:03
- 9.3Constraints“Someone inserted a rating of 7 last time. Can we make the database refuse bad data?”2:10
- 9.4INSERT“Three new sellers onboarded today — Lakshmi Traders, Rao Electronics, Dilli Kart. Add them?”1:43
- 9.5UPDATE & DELETE“Increase prices of all Accessories by 5%. Carefully.”2:00
- 9.6ALTER, DROP, TRUNCATE“We need a gst_number column on sellers — and the old temp tables gone.”2:01
- 9.7Normalization“The sellers team lives in this spreadsheet. Is it normalized? And should it be?”2:13
Mini project Build the seller marketplace
Performance & Reliability
Understand what the database does with your query, make slow queries fast, and keep data consistent when things fail.
6 lessons · 12 min
- 10.1EXPLAINFree“The revenue-by-city dashboard will run on millions of orders next year. What is Postgres actually doing with it?”2:06
- 10.2Indexes“Finding one customer by email scans every row. Can you fix it?”1:59
- 10.3When indexes don't help“I added indexes, but some queries still scan every row. Why?”1:53
- 10.4Transactions“A payment was recorded but the order was never marked paid — the server crashed mid-way. How do we prevent this?”1:51
- 10.5ACID & concurrency“Two people bought the last unit at the same second. We sold stock we didn't have.”2:00
- 10.6Views & materialized views“Can you save the customer-360 query so the team can just SELECT from it?”1:56
Mini project Make the dashboard fast
Real-World Analytics
Combine everything into the analyses companies actually pay for: growth, funnels, cohorts, segmentation.
7 lessons · 14 min
- 11.1Pivoting dataFree“One row per city, one column per payment method — like a spreadsheet pivot.”1:46
- 11.2Date spines & filling gaps“Your daily chart skips days with zero orders. The line looks wrong.”1:55
- 11.3Growth: MoM & YoY“Was Diwali 2025 better than Diwali 2024? By how much?”2:13
- 11.4Conversion funnels“Of people who view a product, how many actually buy? Where do we lose them?”2:02
- 11.5Cohort retention“Do customers who joined in Diwali 2024 stick around better than others?”2:06
- 11.6RFM segmentation“Segment customers so marketing can target Champions and At-Risk separately.”1:49
- 11.7Data quality & deduplication“Before we trust any of this — how clean is the data?”2:00
Mini project The growth review
Career
Interview Prep
Recognise the classic SQL interview patterns instantly and solve them out loud under time pressure.
8 lessons · 16 min
- 12.1How SQL interviews workFree“Which city had the highest revenue last month?”2:07
- 12.2Nth highest value“Find the second most expensive product.”2:15
- 12.3Duplicates: find & delete“Find duplicate customers by email and keep only the oldest.”1:38
- 12.4Consecutive days: gaps & islands“Find customers who ordered on 3 or more consecutive days.”1:59
- 12.5Bought X but not Y“Customers who bought a phone but never a phone case.”1:38
- 12.6Rapid fire: window questions1:58
- 12.7Median & percentiles“What's the median order value? And the 90th percentile?”1:54
- 12.8Mock interview2:20