SQL challenges
Practice SQL with 250 exercises across 14 topics. Browse by topic or filter by difficulty.
SQL fundamentals19 challenges
| Challenge | Progress |
|---|---|
| Select your first columnsEasy | Not started |
| Filter rows with WHEREEasy | Not started |
| Combine conditionsEasy | Not started |
| Sort and limit resultsEasy | Not started |
| Return unique valuesEasy | Not started |
| Summarize rowsEasy | Not started |
| Group and filter summariesModerate | Not started |
| Join albums and salesModerate | Not started |
| Keep unmatched rowsModerate | Not started |
| Build a sales reportHard | Not started |
| Read a single price columnEasy | Not started |
| Find albums with zero stockEasy | Not started |
| Rename a column for a shelf listEasy | Not started |
| Read the second page of albumsModerate | Not started |
| List distinct genre and price pairsModerate | Not started |
| Filter a restock shortlistModerate | Not started |
| Find the highest available price by genreHard | Not started |
| Find unavailable albums without salesHard | Not started |
| Find genres with several salesHard | Not started |
Expressions and missing values19 challenges
| Challenge | Progress |
|---|---|
| Calculate inventory valueEasy | Not started |
| Apply a discountEasy | Not started |
| Label stock levelsModerate | Not started |
| Find names by prefixEasy | Not started |
| Match a single characterEasy | Not started |
| Choose a set of valuesEasy | Not started |
| Filter an inclusive rangeEasy | Not started |
| Slice textModerate | Not started |
| Handle a missing valueModerate | Not started |
| Turn a sentinel into NULLModerate | Not started |
| Measure album title lengthsEasy | Not started |
| Match album titles by suffixEasy | Not started |
| Trim channel labelsEasy | Not started |
| Round a percentage discountModerate | Not started |
| Extract the first word of a titleModerate | Not started |
| Find prices closest to a targetModerate | Not started |
| Apply ordered decision rules to ordersHard | Not started |
| Keep missing averages distinct from zeroHard | Not started |
| Give root categories readable labelsHard | Not started |
Aggregates and reporting19 challenges
| Challenge | Progress |
|---|---|
| Count unique valuesEasy | Not started |
| Compare minimum and maximumEasy | Not started |
| Average within groupsModerate | Not started |
| Count matches after a left joinModerate | Not started |
| Aggregate conditionallyModerate | Not started |
| Use an aggregate filterModerate | Not started |
| Calculate weighted totalsHard | Not started |
| Filter before groupingModerate | Not started |
| Filter on group totalsModerate | Not started |
| Order a summaryModerate | Not started |
| Count all order recordsEasy | Not started |
| Total completed order amountsEasy | Not started |
| Count categories with a parentEasy | Not started |
| Summarize sale sizes by albumModerate | Not started |
| Compare price ranges across genresModerate | Not started |
| Count roots and children in one rowModerate | Not started |
| Calculate each genre’s share of copies soldHard | Not started |
| Compute the average price paid per copyHard | Not started |
| Compare paid orders with paying customersHard | Not started |
Joins and set operations19 challenges
| Challenge | Progress |
|---|---|
| Use aliases in a joinEasy | Not started |
| Join with a second conditionModerate | Not started |
| Keep unmatched rows after filteringModerate | Not started |
| Compare peers with a self joinModerate | Not started |
| Build all combinationsModerate | Not started |
| Join using a shared nameEasy | Not started |
| Combine and deduplicateEasy | Not started |
| Keep duplicates with UNION ALLEasy | Not started |
| Find an intersectionModerate | Not started |
| Subtract setsModerate | Not started |
| Look up the album for one saleEasy | Not started |
| Attach customer names to store ordersEasy | Not started |
| Show each child and its parentEasy | Not started |
| Keep customers with no refundsModerate | Not started |
| Compare channels across two sourcesModerate | Not started |
| Pair orders placed on the same dayModerate | Not started |
| Show which sources contain each channelHard | Not started |
| Find buyers active in exactly one monthHard | Not started |
| Join signups to summarized order totalsHard | Not started |
Subqueries and CTEs19 challenges
| Challenge | Progress |
|---|---|
| Compare against a scalar subqueryEasy | Not started |
| Filter with a subquery listEasy | Not started |
| Test whether a match existsModerate | Not started |
| Find rows with no matchModerate | Not started |
| Correlate an aggregateHard | Not started |
| Query a derived tableModerate | Not started |
| Write your first CTEEasy | Not started |
| Chain CTEsModerate | Not started |
| Join a CTE to a tableModerate | Not started |
| Generate rows recursivelyHard | Not started |
| Find receipts at the minimum amountEasy | Not started |
| Find albums below average stockEasy | Not started |
| Find customers linked to refundsEasy | Not started |
| Find the latest signup from each sourceModerate | Not started |
| Filter albums using a sales summary CTEModerate | Not started |
| Compare album totals with the average sold albumModerate | Not started |
| Compute the median completed order valueHard | Not started |
| Find purchases that set a customer recordHard | Not started |
| Find customers who outspend their signup peersHard | Not started |
Recursive CTEs and hierarchies19 challenges
| Challenge | Progress |
|---|---|
| Generate calendar datesEasy | Not started |
| Find the rootsEasy | Not started |
| Find immediate childrenEasy | Not started |
| Walk a category treeModerate | Not started |
| Track tree depthModerate | Not started |
| Build a readable pathHard | Not started |
| Walk toward the rootHard | Not started |
| Find leaf nodesModerate | Not started |
| Reach nodes in a cyclic graphHard | Not started |
| Summarize a tree by depthHard | Not started |
| Generate a short series of month startsEasy | Not started |
| Generate powers of twoEasy | Not started |
| Count direct children of each categoryEasy | Not started |
| Generate weekly review datesModerate | Not started |
| Find nodes reachable within two stepsModerate | Not started |
| Count descendants under each rootModerate | Not started |
| Measure depth and leaves under each rootHard | Not started |
| Find shortest distances in a cyclic graphHard | Not started |
| Roll album stock up to root categoriesHard | Not started |
Window functions19 challenges
| Challenge | Progress |
|---|---|
| Number rows in orderEasy | Not started |
| Restart numbering by groupEasy | Not started |
| Rank with gapsModerate | Not started |
| Rank without gapsModerate | Not started |
| Compare to a group averageModerate | Not started |
| Calculate a running totalModerate | Not started |
| Calculate a moving averageHard | Not started |
| Read the previous rowModerate | Not started |
| Read the next rowModerate | Not started |
| Pick the top row per groupHard | Not started |
| Number receipts from newest to oldestEasy | Not started |
| Show the total count alongside each orderEasy | Not started |
| Show the cheapest price alongside each albumEasy | Not started |
| Attach the best-stocked title in each genreModerate | Not started |
| Find days since a customer’s previous orderModerate | Not started |
| Track running order revenue by channelModerate | Not started |
| Compare running totals by order and by dayHard | Not started |
| Calculate a moving average over complete windowsHard | Not started |
| Rank customer spending within signup sourcesHard | Not started |
Dates, text, and JSON19 challenges
| Challenge | Progress |
|---|---|
| Extract a calendar monthEasy | Not started |
| Group receipt amounts by monthModerate | Not started |
| Use a half-open date rangeModerate | Not started |
| Compute elapsed daysEasy | Not started |
| Shift a dateEasy | Not started |
| Normalize textEasy | Not started |
| Concatenate labelsEasy | Not started |
| Read a JSON fieldModerate | Not started |
| Filter by JSON array lengthModerate | Not started |
| Expand a JSON array into rowsHard | Not started |
| Read the weekday of an orderEasy | Not started |
| Find the end of each signup monthEasy | Not started |
| Read the first tag on each receiptEasy | Not started |
| Build alphabetical receipt tag labelsModerate | Not started |
| Convert titles to dashed labelsModerate | Not started |
| Label receipts by year and quarterModerate | Not started |
| Count distinct receipts carrying each tagHard | Not started |
| Fill weekday order counts with zeroHard | Not started |
| Add a cleaned channel field to receipt JSONHard | Not started |
Writing and modeling data19 challenges
| Challenge | Progress |
|---|---|
| Insert a new rowEasy | Not started |
| Update selected rowsEasy | Not started |
| Delete selected rowsEasy | Not started |
| Define a constrained tableModerate | Not started |
| Add a columnModerate | Not started |
| Create a viewModerate | Not started |
| Insert from a queryModerate | Not started |
| Upsert on a key conflictHard | Not started |
| Roll back a transactionHard | Not started |
| Inspect foreign keysModerate | Not started |
| Insert a shop order and return its IDEasy | Not started |
| Delete a cancelled order and return its amountEasy | Not started |
| Restock one album and return its new countEasy | Not started |
| Keep the first row for each staging keyModerate | Not started |
| Materialize a restock shortlistModerate | Not started |
| Apply stock changes from a delivery fileModerate | Not started |
| Add new counts to a summary with an upsertHard | Not started |
| Undo one stock edit with a savepointHard | Not started |
| Delete shipment items with a cascadeHard | Not started |
Indexes and query plans19 challenges
| Challenge | Progress |
|---|---|
| Read a full-scan planEasy | Not started |
| Read an indexed searchEasy | Not started |
| Use a primary-key lookupEasy | Not started |
| Observe a composite index prefixModerate | Not started |
| Constrain an indexed rangeModerate | Not started |
| Identify a covering indexModerate | Not started |
| Avoid sorting with an indexModerate | Not started |
| Spot a temporary sortModerate | Not started |
| Create an index and inspect the changeHard | Not started |
| Inspect index definitionsModerate | Not started |
| List the indexes on catalogEasy | Not started |
| Read the receipt date index’s key columnsEasy | Not started |
| Inspect a receipt date equality lookupEasy | Not started |
| Inspect a filter without the leading index keyModerate | Not started |
| Require a specific index in an experimentModerate | Not started |
| Inspect a lookup of several primary keysModerate | Not started |
| Build a covering index for receipt amountsHard | Not started |
| Index a mixed ascending and descending sortHard | Not started |
| Inspect an index’s key sort directionsHard | Not started |
Optimization and capstones19 challenges
| Challenge | Progress |
|---|---|
| Avoid wrapping an indexed dateModerate | Not started |
| Index an expressionHard | Not started |
| Index only qualifying rowsHard | Not started |
| Compare offset and keyset paginationModerate | Not started |
| Inspect a keyset planModerate | Not started |
| Inspect a materialized CTEHard | Not started |
| Analyze database statisticsHard | Not started |
| Rank albums within genresHard | Not started |
| Fill gaps in monthly revenueHard | Not started |
| Build a month-over-month reportHard | Not started |
| Inspect a newest-first date scanEasy | Not started |
| Page through catalog IDs in reverseEasy | Not started |
| Read the distinct genre keys in orderEasy | Not started |
| Page orders with a two-column cursorModerate | Not started |
| Inspect a CTE without materializing itModerate | Not started |
| Index a case-insensitive title searchModerate | Not started |
| Build a sell-through report for every albumHard | Not started |
| Report high-value order share across all monthsHard | Not started |
| Compare inventory value and historical sales by genreHard | Not started |
Customer and sales analytics19 challenges
Data quality and reconciliation11 challenges
| Challenge | Progress |
|---|---|
| Find missing order references in an importEasy | Not started |
| Normalize statuses from an importEasy | Not started |
| Flag unrecognized order statusesEasy | Not started |
| Total refund amounts in the ledgerEasy | Not started |
| Find invalid amounts before castingModerate | Not started |
| Detect duplicate order references after trimmingModerate | Not started |
| Keep the latest imported row per orderModerate | Not started |
| Find ledger orders missing from the order tableModerate | Not started |
| Build a balance from charges and refundsHard | Not started |
| Summarize valid imports after deduplicationHard | Not started |
| Find payment reconciliation discrepanciesHard | Not started |
Product events and funnels11 challenges
| Challenge | Progress |
|---|---|
| Count each kind of product eventEasy | Not started |
| Read the events in one sessionEasy | Not started |
| Count unique January sessionsEasy | Not started |
| Find customers who used searchEasy | Not started |
| Find each active customer’s first eventModerate | Not started |
| Measure elapsed time within a sessionModerate | Not started |
| Find sessions with an abandoned cartModerate | Not started |
| Compare daily active users and purchasersModerate | Not started |
| Find sessions that completed an ordered funnelHard | Not started |
| Measure purchase conversion after a first product viewHard | Not started |
| Find each customer’s longest active-day streakHard | Not started |
