SQL Lab

NEW TO SQL LAB?
STEP 1START HERE

SQL Fundamentals: Read This First

Nine short reading pages - filtering, joins, aggregates, subqueries and window functions - each linked from the cases that need it.

2

Or read the history behind it

The Database Chronicles - How relational query languages revolutionized software.

ACTIVE BOUNTY EVENT
10d left
๐Ÿ†

THE BLACK FRIDAY

Complete all challenges during Black Friday and unlock an exclusive 50% discount on any ScaleDojo plan. Don't miss out!

QUEST PROGRESS0 / 5 COMPLETED
๐ŸŽ 50% Off
LEADERBOARDLIVE

Compare stats and compete with top...

View

CHALLENGE MAP

Progressive SQL Mystery Curriculum

0/50
COMPLETED
2 of 10 levels unlockedยทStart with Level 1 to begin your journey

Solve levels sequentially - each clear unlocks the next challenge

2/10
ACCESSIBLE
Architect Feature: Want to bypass sequential unlock? Go to your Profile and enable Architect's Sandbox.

Act 1

ACT PROGRESS0/10
1

#1 The Vanishing CTO

EasyFresher
๐Ÿ” Vantage Systems Investigation

SELECT โ€ข WHERE

SELECT
WHERE
Standard Challenge
Learn the concepts first
Start Level โ†’

#2 Last Seen

EasyFresher
๐Ÿ” Vantage Systems Investigation

ORDER BY โ€ข LIMIT

ORDER BY
LIMIT
Standard Challenge
Learn the concepts first
Locked

#3 Who Else Was There

EasyFresher
๐Ÿ” Vantage Systems Investigation

DISTINCT

DISTINCT
Standard Challenge
Learn the concepts first
Locked

#4 The Security Lead

EasyFresher
๐Ÿ” Vantage Systems Investigation

AND โ€ข Combining Conditions

AND
Combining Conditions
Standard Challenge
Learn the concepts first
Locked

#5 After Dark

EasyFresher
๐Ÿ” Vantage Systems Investigation

Comparison Operators

Comparison Operators
Standard Challenge
Learn the concepts first
Locked

#6 The Unsigned Visitor

EasyFresher
๐Ÿ” Vantage Systems Investigation

IS NULL

IS NULL
Standard Challenge
Learn the concepts first
Locked

#7 Inside Access

EasyFresher
๐Ÿ” Vantage Systems Investigation

IN

IN
Standard Challenge
Learn the concepts first
Locked

#8 The Critical Window

EasyFresher
๐Ÿ” Vantage Systems Investigation

BETWEEN

BETWEEN
Standard Challenge
Learn the concepts first
Locked

#9 The Money Men

EasyFresher
๐Ÿ” Vantage Systems Investigation

LIKE โ€ข Wildcards

LIKE
Wildcards
Standard Challenge
Learn the concepts first
Locked

#10 No Exit

EasyFresher
๐Ÿ” Vantage Systems Investigation

ORDER BY โ€ข Reading Timelines

ORDER BY
Reading Timelines
Standard Challenge
Learn the concepts first
Locked

Act 2

ACT PROGRESS0/10

#11 Follow the Money

Easy-MediumSDE 1
๐Ÿ” Vantage Systems Investigation

COUNT

COUNT
Standard Challenge
Learn the concepts first
Locked

#12 The Big Number

Easy-MediumSDE 1
๐Ÿ” Vantage Systems Investigation

MAX

MAX
Standard Challenge
Learn the concepts first
Locked

#13 Bleeding Out

Easy-MediumSDE 1
๐Ÿ” Vantage Systems Investigation

SUM

SUM
Standard Challenge
Learn the concepts first
Locked

#14 The Baseline

Easy-MediumSDE 1
๐Ÿ” Vantage Systems Investigation

AVG

AVG
Standard Challenge
Learn the concepts first
Locked

#15 Vendor Roll Call

Easy-MediumSDE 1Stripe
๐Ÿ” Vantage Systems Investigation

GROUP BY โ€ข COUNT

GROUP BY
COUNT
Standard Challenge
Learn the concepts first
Locked

#16 The Heavy Hitters

Easy-MediumSDE 1StripePayPal
๐Ÿ” Vantage Systems Investigation

GROUP BY โ€ข HAVING โ€ข SUM

GROUP BY
HAVING
SUM
Standard Challenge
Learn the concepts first
Locked

#17 Midnight Money

Easy-MediumSDE 1Stripe
๐Ÿ” Vantage Systems Investigation

Date & Time Functions

Date & Time Functions
Standard Challenge
Learn the concepts first
Locked

#18 The Doctored Invoice

Easy-MediumSDE 1PayPal
๐Ÿ” Vantage Systems Investigation

Comparing Columns

Comparing Columns
Standard Challenge
Learn the concepts first
Locked

#19 The Spike

Easy-MediumSDE 1Stripe
๐Ÿ” Vantage Systems Investigation

GROUP BY โ€ข strftime

GROUP BY
strftime
Standard Challenge
Learn the concepts first
Locked

#20 The Discretionary Drain

Easy-MediumSDE 1
๐Ÿ” Vantage Systems Investigation

DISTINCT โ€ข WHERE

DISTINCT
WHERE
Standard Challenge
Learn the concepts first
Locked

Act 3

ACT PROGRESS0/10

#21 Names, Not Numbers

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

INNER JOIN

INNER JOIN
Standard Challenge
Learn the concepts first
Locked

#22 The Whistleblower

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

JOIN โ€ข LIKE

JOIN
LIKE
Standard Challenge
Learn the concepts first
Locked

#23 Come Alone

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

Self-referencing JOINs โ€ข Table Aliases

Self-referencing JOINs
Table Aliases
Standard Challenge
Learn the concepts first
Locked

#24 The Ghost

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

LEFT JOIN โ€ข IS NULL

LEFT JOIN
IS NULL
Standard Challenge
Learn the concepts first
Locked

#25 Damage Control

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

JOIN

JOIN
Standard Challenge
Learn the concepts first
Locked

#26 Knock Knock

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

JOIN โ€ข Filtering

JOIN
Filtering
Standard Challenge
Learn the concepts first
Locked

#27 The Source Account

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

JOIN

JOIN
Standard Challenge
Learn the concepts first
Locked

#28 The Empty Chairs

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

LEFT JOIN โ€ข IS NULL

LEFT JOIN
IS NULL
Standard Challenge
Learn the concepts first
Locked

#29 Sessions Left Open

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

JOIN โ€ข IS NULL

JOIN
IS NULL
Standard Challenge
Learn the concepts first
Locked

#30 The Cleanup Crew

MediumSDE 2
๐Ÿ” Vantage Systems Investigation

Multiple JOINs โ€ข LIKE

Multiple JOINs
LIKE
Standard Challenge
Learn the concepts first
Locked

Act 4

ACT PROGRESS0/10

#31 Above the Waterline

Medium-HardSDE 2
๐Ÿ” Vantage Systems Investigation

Scalar Subquery

Scalar Subquery
Standard Challenge
Learn the concepts first
Locked

#32 Shells on the Books

Medium-HardSDE 2PayPal
๐Ÿ” Vantage Systems Investigation

IN Subquery

IN Subquery
Standard Challenge
Learn the concepts first
Locked

#33 The Common Thread

Medium-HardSDE 2PayPal
๐Ÿ” Vantage Systems Investigation

GROUP BY โ€ข HAVING โ€ข COUNT

GROUP BY
HAVING
COUNT
Standard Challenge
Learn the concepts first
Locked

#34 Not on the List

Medium-HardSDE 2Stripe
๐Ÿ” Vantage Systems Investigation

EXCEPT

EXCEPT
Standard Challenge
Learn the concepts first
Locked

#35 All the Outflows

Medium-HardSDE 2
๐Ÿ” Vantage Systems Investigation

UNION

UNION
Standard Challenge
Learn the concepts first
Locked

#36 The Whale

HardSDE 3
๐Ÿ” Vantage Systems Investigation

Subquery with MAX

Subquery with MAX
Standard Challenge
Learn the concepts first
Locked

#37 The Funnel

HardSDE 3
๐Ÿ” Vantage Systems Investigation

CTE (WITH)

CTE (WITH)
Standard Challenge
Learn the concepts first
Locked

#38 Two Levels Down

HardSDE 3
๐Ÿ” Vantage Systems Investigation

Nested Subqueries

Nested Subqueries
Standard Challenge
Learn the concepts first
Locked

#39 Built to Vanish

HardSDE 3
๐Ÿ” Vantage Systems Investigation

Date Arithmetic โ€ข julianday

Date Arithmetic
julianday
Standard Challenge
Learn the concepts first
Locked

#40 The Alias

HardSDE 3
๐Ÿ” Vantage Systems Investigation

CTE (WITH) โ€ข IN Subquery

CTE (WITH)
IN Subquery
Standard Challenge
Learn the concepts first
Locked

Act 5

ACT PROGRESS0/10

#41 The Million Mark

HardSDE 3AmazonNetflix
๐Ÿ” Vantage Systems Investigation

Window Functions โ€ข SUM OVER

Window Functions
SUM OVER
Standard Challenge
Learn the concepts first
Locked

#42 Top of Each Stack

HardSDE 3AmazonUber
๐Ÿ” Vantage Systems Investigation

ROW_NUMBER โ€ข PARTITION BY

ROW_NUMBER
PARTITION BY
Standard Challenge
Learn the concepts first
Locked

#43 The Hole in the Patrol

HardSDE 3UberDoorDash
๐Ÿ” Vantage Systems Investigation

LAG โ€ข Window Ordering

LAG
Window Ordering
Standard Challenge
Learn the concepts first
Locked

#44 The Lion's Share

HardStaff+AmazonNetflix
๐Ÿ” Vantage Systems Investigation

Window over Aggregate โ€ข Percent of Total

Window over Aggregate
Percent of Total
Standard Challenge
Learn the concepts first
Locked

#45 Against Their Own Average

HardSDE 3
๐Ÿ” Vantage Systems Investigation

Correlated Subquery

Correlated Subquery
Standard Challenge
Learn the concepts first
Locked

#46 First Contact

ExpertSDE 3MetaLinkedIn
๐Ÿ” Vantage Systems Investigation

MIN OVER โ€ข PARTITION BY

MIN OVER
PARTITION BY
Standard Challenge
Learn the concepts first
Locked

#47 The Alibi Cracks

ExpertSDE 3
๐Ÿ” Vantage Systems Investigation

Filtering โ€ข Timestamps โ€ข Synthesis

Filtering
Timestamps
Synthesis
Standard Challenge
Learn the concepts first
Locked

#48 Follow the Rank

ExpertStaff+AmazonNetflixUber
๐Ÿ” Vantage Systems Investigation

RANK โ€ข Window over GROUP BY

RANK
Window over GROUP BY
Standard Challenge
Learn the concepts first
Locked

#49 The Last Message

ExpertSDE 3
๐Ÿ” Vantage Systems Investigation

MAX โ€ข Synthesis

MAX
Synthesis
Standard Challenge
Learn the concepts first
Locked

#50 Name the Mastermind

LegendaryStaff+AmazonGoogle
๐Ÿ” Vantage Systems Investigation

CTE Chains โ€ข Synthesis โ€ข The Whole Toolbox

CTE Chains
Synthesis
The Whole Toolbox
Standard Challenge
Learn the concepts first
Locked

Act 6

ACT PROGRESS0/5

#51 Generations

EasySDE 1AirbnbLinkedIn
๐Ÿ” Vantage Systems Investigation

CASE โ€ข Bucketing โ€ข GROUP BY

CASE
Bucketing
GROUP BY
Standard Challenge
Learn the concepts first
Locked

#52 Three Counters at Once

MediumSDE 2AmazonMeta
๐Ÿ” Vantage Systems Investigation

CASE โ€ข COUNT โ€ข GROUP BY

CASE
COUNT
GROUP BY
Standard Challenge
Learn the concepts first
Locked

#53 Unknown Is Not Zero

MediumSDE 2AirbnbUber
๐Ÿ” Vantage Systems Investigation

COALESCE โ€ข NULLIF โ€ข LEFT JOIN

COALESCE
NULLIF
LEFT JOIN
Standard Challenge
Learn the concepts first
Locked

#54 Share of the Whole

MediumSDE 2GoogleStripe
๐Ÿ” Vantage Systems Investigation

Percent of Total โ€ข Subquery โ€ข ROUND

Percent of Total
Subquery
ROUND
Standard Challenge
Learn the concepts first
Locked

#55 Months in Columns

MediumSDE 2AmazonStripe
๐Ÿ” Vantage Systems Investigation

CASE โ€ข Conditional Aggregation โ€ข Pivot

CASE
Conditional Aggregation
Pivot
Standard Challenge
Learn the concepts first
Locked

Act 7

ACT PROGRESS0/5

#56 Never Ordered

MediumSDE 2AirbnbUber
๐Ÿ” Vantage Systems Investigation

Anti-Join โ€ข NOT EXISTS โ€ข LEFT JOIN

Anti-Join
NOT EXISTS
LEFT JOIN
Standard Challenge
Learn the concepts first
Locked

#57 The Org Chart

MediumSDE 2MicrosoftLinkedIn
๐Ÿ” Vantage Systems Investigation

Self Join โ€ข LEFT JOIN

Self Join
LEFT JOIN
Standard Challenge
Learn the concepts first
Locked

#58 New in the Second Quarter

MediumSDE 2GoogleLinkedIn
๐Ÿ” Vantage Systems Investigation

EXCEPT โ€ข INTERSECT โ€ข Set Operations

EXCEPT
INTERSECT
Set Operations
Standard Challenge
Learn the concepts first
Locked

#59 Electronics Fans

MediumSDE 2AmazonMeta
๐Ÿ” Vantage Systems Investigation

EXISTS โ€ข Correlated Subquery

EXISTS
Correlated Subquery
Standard Challenge
Learn the concepts first
Locked

#60 Above Their Own Category Average

HardSDE 3AmazonGoogle
๐Ÿ” Vantage Systems Investigation

Correlated Subquery โ€ข AVG

Correlated Subquery
AVG
Standard Challenge
Learn the concepts first
Locked

Act 8

ACT PROGRESS0/5

#61 The Second Price Tier

MediumSDE 2AmazonMeta
๐Ÿ” Vantage Systems Investigation

DENSE_RANK โ€ข PARTITION BY

DENSE_RANK
PARTITION BY
Standard Challenge
Learn the concepts first
Locked

#62 Latest Order, Beside Every Order

HardSDE 3AmazonAirbnb
๐Ÿ” Vantage Systems Investigation

FIRST_VALUE โ€ข PARTITION BY โ€ข Window Ordering

FIRST_VALUE
PARTITION BY
Window Ordering
Standard Challenge
Learn the concepts first
Locked

#63 Days Between Orders

HardSDE 3AmazonUber
๐Ÿ” Vantage Systems Investigation

LAG โ€ข PARTITION BY โ€ข julianday

LAG
PARTITION BY
julianday
Standard Challenge
Learn the concepts first
Locked

#64 Spend Quartiles

HardSDE 3GoogleStripe
๐Ÿ” Vantage Systems Investigation

NTILE โ€ข CTE โ€ข Ranking

NTILE
CTE
Ranking
Standard Challenge
Learn the concepts first
Locked

#65 The Three-Order Average

HardSDE 3GoogleNetflix
๐Ÿ” Vantage Systems Investigation

Window Frame โ€ข ROWS BETWEEN โ€ข AVG OVER

Window Frame
ROWS BETWEEN
AVG OVER
Standard Challenge
Learn the concepts first
Locked

Act 9

ACT PROGRESS0/5

#66 Signed Up, Then Came Back

HardSDE 3GoogleAirbnb
๐Ÿ” Vantage Systems Investigation

Cohorts โ€ข EXISTS โ€ข Date Arithmetic

Cohorts
EXISTS
Date Arithmetic
Standard Challenge
Learn the concepts first
Locked

#67 Where Shoppers Drop Off

HardSDE 3AmazonMeta
๐Ÿ” Vantage Systems Investigation

Funnel โ€ข COUNT DISTINCT โ€ข Subquery

Funnel
COUNT DISTINCT
Subquery
Standard Challenge
Learn the concepts first
Locked

#68 Every Day, Even the Quiet Ones

HardSDE 3AmazonStripe
๐Ÿ” Vantage Systems Investigation

Recursive CTE โ€ข Date Spine โ€ข LEFT JOIN

Recursive CTE
Date Spine
LEFT JOIN
Standard Challenge
Learn the concepts first
Locked

#69 The Longest Streak

HardSDE 3GoogleAmazon
๐Ÿ” Vantage Systems Investigation

Gaps and Islands โ€ข ROW_NUMBER โ€ข Date Arithmetic

Gaps and Islands
ROW_NUMBER
Date Arithmetic
Standard Challenge
Learn the concepts first
Locked

#70 How Many Visits?

HardSDE 3GoogleMeta
๐Ÿ” Vantage Systems Investigation

Sessionization โ€ข LAG โ€ข Window Functions

Sessionization
LAG
Window Functions
Standard Challenge
Learn the concepts first
Locked

Act 10

ACT PROGRESS0/5

#71 Fourth-Highest Salary

MediumSDE 2AmazonGoogleMicrosoft
๐Ÿ” Vantage Systems Investigation

DISTINCT โ€ข LIMIT OFFSET โ€ข DENSE_RANK

DISTINCT
LIMIT OFFSET
DENSE_RANK
Standard Challenge
Learn the concepts first
Locked

#72 Keep Only the Latest

MediumSDE 2AirbnbStripeLinkedIn
๐Ÿ” Vantage Systems Investigation

ROW_NUMBER โ€ข Deduplication โ€ข Latest Row Per Group

ROW_NUMBER
Deduplication
Latest Row Per Group
Standard Challenge
Learn the concepts first
Locked

#73 The Median Salary

HardSDE 3GoogleMeta
๐Ÿ” Vantage Systems Investigation

Median โ€ข LIMIT OFFSET โ€ข Subquery

Median
LIMIT OFFSET
Subquery
Standard Challenge
Learn the concepts first
Locked

#74 Top Three Pay Bands per Department

HardSDE 3AmazonGoogleMeta
๐Ÿ” Vantage Systems Investigation

DENSE_RANK โ€ข Top-N per Group โ€ข Ties

DENSE_RANK
Top-N per Group
Ties
Standard Challenge
Learn the concepts first
Locked

#75 Bought A and B, but Not C

HardSDE 3AmazonAirbnbUber
๐Ÿ” Vantage Systems Investigation

HAVING โ€ข Conditional Aggregation โ€ข Set Logic

HAVING
Conditional Aggregation
Set Logic
Standard Challenge
Learn the concepts first
Locked