SQL Challenger

SQL challenges

Practice SQL with 250 exercises across 14 topics. Browse by topic or filter by difficulty.

Start practicing

SQL fundamentals19 challenges
SQL fundamentals challenges
ChallengeProgress
Select your first columnsEasyNot started
Filter rows with WHEREEasyNot started
Combine conditionsEasyNot started
Sort and limit resultsEasyNot started
Return unique valuesEasyNot started
Summarize rowsEasyNot started
Group and filter summariesModerateNot started
Join albums and salesModerateNot started
Keep unmatched rowsModerateNot started
Build a sales reportHardNot started
Read a single price columnEasyNot started
Find albums with zero stockEasyNot started
Rename a column for a shelf listEasyNot started
Read the second page of albumsModerateNot started
List distinct genre and price pairsModerateNot started
Filter a restock shortlistModerateNot started
Find the highest available price by genreHardNot started
Find unavailable albums without salesHardNot started
Find genres with several salesHardNot started
Expressions and missing values19 challenges
Expressions and missing values challenges
ChallengeProgress
Calculate inventory valueEasyNot started
Apply a discountEasyNot started
Label stock levelsModerateNot started
Find names by prefixEasyNot started
Match a single characterEasyNot started
Choose a set of valuesEasyNot started
Filter an inclusive rangeEasyNot started
Slice textModerateNot started
Handle a missing valueModerateNot started
Turn a sentinel into NULLModerateNot started
Measure album title lengthsEasyNot started
Match album titles by suffixEasyNot started
Trim channel labelsEasyNot started
Round a percentage discountModerateNot started
Extract the first word of a titleModerateNot started
Find prices closest to a targetModerateNot started
Apply ordered decision rules to ordersHardNot started
Keep missing averages distinct from zeroHardNot started
Give root categories readable labelsHardNot started
Aggregates and reporting19 challenges
Aggregates and reporting challenges
ChallengeProgress
Count unique valuesEasyNot started
Compare minimum and maximumEasyNot started
Average within groupsModerateNot started
Count matches after a left joinModerateNot started
Aggregate conditionallyModerateNot started
Use an aggregate filterModerateNot started
Calculate weighted totalsHardNot started
Filter before groupingModerateNot started
Filter on group totalsModerateNot started
Order a summaryModerateNot started
Count all order recordsEasyNot started
Total completed order amountsEasyNot started
Count categories with a parentEasyNot started
Summarize sale sizes by albumModerateNot started
Compare price ranges across genresModerateNot started
Count roots and children in one rowModerateNot started
Calculate each genre’s share of copies soldHardNot started
Compute the average price paid per copyHardNot started
Compare paid orders with paying customersHardNot started
Joins and set operations19 challenges
Joins and set operations challenges
ChallengeProgress
Use aliases in a joinEasyNot started
Join with a second conditionModerateNot started
Keep unmatched rows after filteringModerateNot started
Compare peers with a self joinModerateNot started
Build all combinationsModerateNot started
Join using a shared nameEasyNot started
Combine and deduplicateEasyNot started
Keep duplicates with UNION ALLEasyNot started
Find an intersectionModerateNot started
Subtract setsModerateNot started
Look up the album for one saleEasyNot started
Attach customer names to store ordersEasyNot started
Show each child and its parentEasyNot started
Keep customers with no refundsModerateNot started
Compare channels across two sourcesModerateNot started
Pair orders placed on the same dayModerateNot started
Show which sources contain each channelHardNot started
Find buyers active in exactly one monthHardNot started
Join signups to summarized order totalsHardNot started
Subqueries and CTEs19 challenges
Subqueries and CTEs challenges
ChallengeProgress
Compare against a scalar subqueryEasyNot started
Filter with a subquery listEasyNot started
Test whether a match existsModerateNot started
Find rows with no matchModerateNot started
Correlate an aggregateHardNot started
Query a derived tableModerateNot started
Write your first CTEEasyNot started
Chain CTEsModerateNot started
Join a CTE to a tableModerateNot started
Generate rows recursivelyHardNot started
Find receipts at the minimum amountEasyNot started
Find albums below average stockEasyNot started
Find customers linked to refundsEasyNot started
Find the latest signup from each sourceModerateNot started
Filter albums using a sales summary CTEModerateNot started
Compare album totals with the average sold albumModerateNot started
Compute the median completed order valueHardNot started
Find purchases that set a customer recordHardNot started
Find customers who outspend their signup peersHardNot started
Recursive CTEs and hierarchies19 challenges
Recursive CTEs and hierarchies challenges
ChallengeProgress
Generate calendar datesEasyNot started
Find the rootsEasyNot started
Find immediate childrenEasyNot started
Walk a category treeModerateNot started
Track tree depthModerateNot started
Build a readable pathHardNot started
Walk toward the rootHardNot started
Find leaf nodesModerateNot started
Reach nodes in a cyclic graphHardNot started
Summarize a tree by depthHardNot started
Generate a short series of month startsEasyNot started
Generate powers of twoEasyNot started
Count direct children of each categoryEasyNot started
Generate weekly review datesModerateNot started
Find nodes reachable within two stepsModerateNot started
Count descendants under each rootModerateNot started
Measure depth and leaves under each rootHardNot started
Find shortest distances in a cyclic graphHardNot started
Roll album stock up to root categoriesHardNot started
Window functions19 challenges
Window functions challenges
ChallengeProgress
Number rows in orderEasyNot started
Restart numbering by groupEasyNot started
Rank with gapsModerateNot started
Rank without gapsModerateNot started
Compare to a group averageModerateNot started
Calculate a running totalModerateNot started
Calculate a moving averageHardNot started
Read the previous rowModerateNot started
Read the next rowModerateNot started
Pick the top row per groupHardNot started
Number receipts from newest to oldestEasyNot started
Show the total count alongside each orderEasyNot started
Show the cheapest price alongside each albumEasyNot started
Attach the best-stocked title in each genreModerateNot started
Find days since a customer’s previous orderModerateNot started
Track running order revenue by channelModerateNot started
Compare running totals by order and by dayHardNot started
Calculate a moving average over complete windowsHardNot started
Rank customer spending within signup sourcesHardNot started
Dates, text, and JSON19 challenges
Dates, text, and JSON challenges
ChallengeProgress
Extract a calendar monthEasyNot started
Group receipt amounts by monthModerateNot started
Use a half-open date rangeModerateNot started
Compute elapsed daysEasyNot started
Shift a dateEasyNot started
Normalize textEasyNot started
Concatenate labelsEasyNot started
Read a JSON fieldModerateNot started
Filter by JSON array lengthModerateNot started
Expand a JSON array into rowsHardNot started
Read the weekday of an orderEasyNot started
Find the end of each signup monthEasyNot started
Read the first tag on each receiptEasyNot started
Build alphabetical receipt tag labelsModerateNot started
Convert titles to dashed labelsModerateNot started
Label receipts by year and quarterModerateNot started
Count distinct receipts carrying each tagHardNot started
Fill weekday order counts with zeroHardNot started
Add a cleaned channel field to receipt JSONHardNot started
Writing and modeling data19 challenges
Writing and modeling data challenges
ChallengeProgress
Insert a new rowEasyNot started
Update selected rowsEasyNot started
Delete selected rowsEasyNot started
Define a constrained tableModerateNot started
Add a columnModerateNot started
Create a viewModerateNot started
Insert from a queryModerateNot started
Upsert on a key conflictHardNot started
Roll back a transactionHardNot started
Inspect foreign keysModerateNot started
Insert a shop order and return its IDEasyNot started
Delete a cancelled order and return its amountEasyNot started
Restock one album and return its new countEasyNot started
Keep the first row for each staging keyModerateNot started
Materialize a restock shortlistModerateNot started
Apply stock changes from a delivery fileModerateNot started
Add new counts to a summary with an upsertHardNot started
Undo one stock edit with a savepointHardNot started
Delete shipment items with a cascadeHardNot started
Indexes and query plans19 challenges
Indexes and query plans challenges
ChallengeProgress
Read a full-scan planEasyNot started
Read an indexed searchEasyNot started
Use a primary-key lookupEasyNot started
Observe a composite index prefixModerateNot started
Constrain an indexed rangeModerateNot started
Identify a covering indexModerateNot started
Avoid sorting with an indexModerateNot started
Spot a temporary sortModerateNot started
Create an index and inspect the changeHardNot started
Inspect index definitionsModerateNot started
List the indexes on catalogEasyNot started
Read the receipt date index’s key columnsEasyNot started
Inspect a receipt date equality lookupEasyNot started
Inspect a filter without the leading index keyModerateNot started
Require a specific index in an experimentModerateNot started
Inspect a lookup of several primary keysModerateNot started
Build a covering index for receipt amountsHardNot started
Index a mixed ascending and descending sortHardNot started
Inspect an index’s key sort directionsHardNot started
Optimization and capstones19 challenges
Optimization and capstones challenges
ChallengeProgress
Avoid wrapping an indexed dateModerateNot started
Index an expressionHardNot started
Index only qualifying rowsHardNot started
Compare offset and keyset paginationModerateNot started
Inspect a keyset planModerateNot started
Inspect a materialized CTEHardNot started
Analyze database statisticsHardNot started
Rank albums within genresHardNot started
Fill gaps in monthly revenueHardNot started
Build a month-over-month reportHardNot started
Inspect a newest-first date scanEasyNot started
Page through catalog IDs in reverseEasyNot started
Read the distinct genre keys in orderEasyNot started
Page orders with a two-column cursorModerateNot started
Inspect a CTE without materializing itModerateNot started
Index a case-insensitive title searchModerateNot started
Build a sell-through report for every albumHardNot started
Report high-value order share across all monthsHardNot started
Compare inventory value and historical sales by genreHardNot started
Customer and sales analytics19 challenges
Customer and sales analytics challenges
ChallengeProgress
Count orders by channel and statusEasyNot started
Calculate revenue by sales channelModerateNot started
Find customers who have never boughtModerateNot started
Measure repeat buyers by signup sourceHardNot started
Count first-time buyers by monthModerateNot started
Find each customer’s second orderModerateNot started
Calculate days to a first purchaseModerateNot started
Measure 30-day signup conversionHardNot started
Build an activity table by signup cohortHardNot started
Measure next-month buyer retentionHardNot started
List orders that did not completeEasyNot started
Display completed amounts in currency unitsEasyNot started
Find channels with more than one order statusEasyNot started
Pick each buyer’s largest orderModerateNot started
Compare order values by signup sourceModerateNot started
Compute the refund rate by channelModerateNot started
Split monthly revenue into first and repeat purchasesHardNot started
Report each repeat buyer’s longest order gapHardNot started
Find buyers who purchased through multiple channelsHardNot started
Data quality and reconciliation11 challenges
Data quality and reconciliation challenges
ChallengeProgress
Find missing order references in an importEasyNot started
Normalize statuses from an importEasyNot started
Flag unrecognized order statusesEasyNot started
Total refund amounts in the ledgerEasyNot started
Find invalid amounts before castingModerateNot started
Detect duplicate order references after trimmingModerateNot started
Keep the latest imported row per orderModerateNot started
Find ledger orders missing from the order tableModerateNot started
Build a balance from charges and refundsHardNot started
Summarize valid imports after deduplicationHardNot started
Find payment reconciliation discrepanciesHardNot started
Product events and funnels11 challenges
Product events and funnels challenges
ChallengeProgress
Count each kind of product eventEasyNot started
Read the events in one sessionEasyNot started
Count unique January sessionsEasyNot started
Find customers who used searchEasyNot started
Find each active customer’s first eventModerateNot started
Measure elapsed time within a sessionModerateNot started
Find sessions with an abandoned cartModerateNot started
Compare daily active users and purchasersModerateNot started
Find sessions that completed an ordered funnelHardNot started
Measure purchase conversion after a first product viewHardNot started
Find each customer’s longest active-day streakHardNot started