THE SQL PRACTICE ARENA
Think in SQL.
Play to win.
Explore 250 original problems, learn from worked examples, and draft queries in your browser.
250 original problems
Open any problem to see its schema and worked example.
Timed contests ↗
Host a 45- or 60-minute room with live standings.
Live 1v1 duels ↗
Share an invite and race a friend on the same problem.
PRACTICE BANK
Pick your next query.
250 problems
- 001The quiet customersLEFT JOIN · NULLEasy
- 002Teams above the thresholdGROUP BY · HAVINGEasy
- 003Stock below the reorder pointSELECT · WHEREEasy
- 004Regions with active customersDISTINCT · NULLEasy
- 005Repeat buyersGROUP BY · HAVINGEasy
- 006Include teams without workLEFT JOIN · COUNTMedium
- 007Products never purchasedNOT EXISTS · SubqueryEasy
- 008Salaries above the team averageCTE · AVG · JOINMedium
- 009Second highest distinct salaryDENSE_RANK · Window functionsMedium
- 010Latest order per customerROW_NUMBER · Window functionsMedium
- 011Running account balanceSUM · Window functionsMedium
- 012Top two products in each categoryDENSE_RANK · TiesMedium
- 013Three consecutive active daysCTE · Self join · DISTINCTHard
- 014Candidates with all required skillsRelational division · NOT EXISTSHard
- 015The out-of-stock shelfWHERE · NULLEasy
- 016Inside the budget bandBETWEENEasy
- 017A team still to be assignedIS NULLEasy
- 018Money flowing outWHERE · ArithmeticEasy
- 019A usable contact addressTRIM · NULLEasy
- 020The C shelfLIKEEasy
- 021The first three daysWHERE · ANDEasy
- 022The urgent queueWHERE · IS NULLEasy
- 023The category directoryDISTINCTEasy
- 024January arrivalsSUBSTR · DatesEasy
- 025Units orderedSUM · GROUP BYEasy
- 026A sensor's rangeMIN · MAXEasy
- 027Open versus closedCASE · SUMEasy
- 028How complete is payroll?COUNT · NULLEasy
- 029Busy order daysCOUNT DISTINCT · HAVINGEasy
- 030The ledger totalSUM · COALESCEEasy
- 031Monthly arrivalsSUBSTR · GROUP BY · DatesEasy
- 032Paid orders by dayWHERE · COUNTEasy
- 033Name the inventory stateCASEEasy
- 034How long did it take?CASE · ArithmeticEasy
- 035A city for every customerCOALESCEEasy
- 036Distance from the benchmarkABS · ArithmeticEasy
- 037The price-ordered catalogORDER BYEasy
- 038Three seats on the premium shelfORDER BY · LIMITEasy
- 039Put a name to the orderINNER JOINEasy
- 040Meet the managerSelf joinEasy
- 041Seats filled in every courseLEFT JOIN · COUNTEasy
- 042Reprice each order lineJOIN · ArithmeticEasy
- 043Successful students and coursesJOIN · DISTINCTEasy
- 044The first-day snapshotMIN · SubqueryEasy
- 045Names across two directoriesUNIONEasy
- 046Both paid and cancelledINTERSECTEasy
- 047No course chosen yetEXCEPTEasy
- 048The active northern listAND · OREasy
- 049Everyone's paid totalLEFT JOIN · SUM · COALESCEMedium
- 050Pricier than its peersCorrelated subquery · AVGMedium
- 051The newest ticket in each teamROW_NUMBER · CTEMedium
- 052One address, multiple accountsLOWER · TRIM · HAVINGMedium
- 053A taste for different categoriesCOUNT DISTINCT · JOINMedium
- 054When the quote disagreesJOIN · NULLMedium
- 055Cancelled, never convertedEXISTS · NOT EXISTSMedium
- 056Payroll without missing valuesHAVING · COUNTMedium
- 057Teams above the company benchmarkAVG · Subquery · HAVINGMedium
- 058The dominant priorityCTE · DENSE_RANKMedium
- 059A change from the previous observed monthLAG · SUM · CTEMedium
- 060Two leaderboard positions per teamRANK · TiesMedium
- 061Earning more than your managerSelf join · ArithmeticMedium
- 062Dense positions each roundDENSE_RANK · Window functionsMedium
- 063A device's high-water markMAX · Window frameMedium
- 064Time since the previous readingLAG · ArithmeticMedium
- 065Peek at the next rowLEAD · NULLMedium
- 066A user's activity spanMIN · MAX · COUNT DISTINCTMedium
- 067What did they buy first?ROW_NUMBER · CTEMedium
- 068The second paid purchaseROW_NUMBERMedium
- 069The sensor did not moveLAG · CTEMedium
- 070Never a step backwardsLAG · NOT EXISTSMedium
- 071A course results panelCASE · Conditional aggregationMedium
- 072Teams balancing both queuesHAVING · CASEMedium
- 073Two colleagues, one pairSelf join · PairsMedium
- 074Both the drink and the readingJOIN · HAVINGMedium
- 075Repeated success recordsGROUP BY · HAVINGMedium
- 076Their current last orderROW_NUMBER · LEFT JOINMedium
- 077Real customers, real purchase daysINNER JOIN · DISTINCTMedium
- 078Three readings at a timeWindow frame · SUMMedium
- 079Every node's immediate familySelf join · LEFT JOINMedium
- 080Orders with broken linksNOT EXISTS · ORMedium
- 081Daily paid basket valueCTE · JOIN · SUMMedium
- 082Four payroll bucketsNTILE · Window functionsMedium
- 083The longest activity streakGaps and islands · ROW_NUMBER · CTEHard
- 084Merge the time on screenGaps and islands · Window frame · MAXHard
- 085Between two active daysLEAD · DISTINCT · CTEHard
- 086The two middle salariesMedian · ROW_NUMBER · COUNTHard
- 087Who carries half the payroll?SUM · Window frame · CTEHard
- 088The first hundredRunning total · ROW_NUMBER · CTEHard
- 089The biggest leap each roundLAG · DENSE_RANK · CTEHard
- 090Seven calendar days, not seven rowsRange join · SUMHard
- 091How many buyers have we reached?CTE · Correlated subquery · COUNTHard
- 092A complete required curriculumRelational division · NOT EXISTSHard
- 093A buyer in every categoryRelational division · JOINHard
- 094Never beaten in a played roundNOT EXISTS · Correlated subqueryHard
- 095A funnel in the right orderEXISTS · FunnelHard
- 096Did the new cohort return?Cohorts · EXISTS · CASEHard
- 097Three days out of the pictureMAX · CTE · LEFT JOINHard
- 098Find your depth in the forestRecursive CTE · TreesHard
- 099How many leaves below each node?Recursive CTE · NOT EXISTS · COUNTHard
- 100Fill the calendar's holesRecursive CTE · NOT EXISTS · DatesHard
- 101A short read for the weekendWHERE · BETWEENEasy
- 102Still on the reader's shelfIS NULLEasy
- 103Pages across the shelvesGROUP BY · SUMEasy
- 104Returned past the deadlineArithmetic · WHEREEasy
- 105Readers who cross genresJOIN · COUNT DISTINCTMedium
- 106Each reader's latest checkoutROW_NUMBER · LEFT JOINMedium
- 107Genres with an untouched bookNOT EXISTS · DISTINCTMedium
- 108A book worth borrowing againGROUP BY · HAVINGMedium
- 109Overlapping loans by the same readerSelf join · IntervalsHard
- 110The quickest completed read in each genreCTE · DENSE_RANK · JOINHard
- 111Minutes beyond the promiseWHERE · ArithmeticEasy
- 112The free delivery listWHEREEasy
- 113Where the kitchens areDISTINCT · NULLEasy
- 114Completed drops per riderCOUNT · GROUP BYEasy
- 115Kitchens with no successful dropNOT EXISTSMedium
- 116Each rider's promise recordLEFT JOIN · CASEMedium
- 117Delivery fees by known zoneJOIN · SUMMedium
- 118Time between completed dropsLAG · CTEMedium
- 119Longest on-time delivery streakGaps and islands · Window functionsHard
- 120The fastest kitchen in each zoneCTE · DENSE_RANKHard
- 121Flights with room to offerWHERE · ANDEasy
- 122Paid seats by flight IDSUM · GROUP BYEasy
- 123Cities in the airport directoryDISTINCTEasy
- 124Reservations awaiting paymentWHEREEasy
- 125Flights without a paid bookingNOT EXISTSMedium
- 126The seat availability panelLEFT JOIN · COALESCE · SUMMedium
- 127Every airport's flight movementsUNION ALL · LEFT JOINMedium
- 128Passengers reaching multiple citiesCOUNT DISTINCT · JOINMedium
- 129The booking that filled the planeRunning total · ROW_NUMBERHard
- 130A connection you can actually makeSelf join · EXISTS · IntervalsHard
- 131Hours already checked offSUM · WHEREEasy
- 132The top-level work listIS NULLEasy
- 133Projects with a small budgetBETWEENEasy
- 134Work without an estimateNULL · WHEREEasy
- 135The project completion panelLEFT JOIN · CASEMedium
- 136Estimated effort beyond budgetGROUP BY · HAVINGMedium
- 137Parents with unfinished childrenSelf join · COUNTMedium
- 138Projects ready to archiveEXISTS · NOT EXISTSMedium
- 139The longest dependency chainRecursive CTE · TreesHard
- 140Completed before the prerequisitesRecursive CTE · EXISTSHard
- 141Inventory arriving at the doorWHEREEasy
- 142Net units by SKUGROUP BY · SUMEasy
- 143Warehouses that shipped somethingDISTINCT · WHEREEasy
- 144SKUs with a reorder thresholdIS NOT NULLEasy
- 145Reorder checks at every warehouseCROSS JOIN · LEFT JOIN · SUMMedium
- 146Busy, but back to zeroGROUP BY · HAVINGMedium
- 147Movement rows with broken referencesNOT EXISTS · ORMedium
- 148The latest stock movementROW_NUMBERMedium
- 149The first negative stock balanceRunning total · ROW_NUMBER · CTEHard
- 150A complete, always-covered warehouseRelational division · Window functionsHard
- 151Appointments marked no-showWHEREEasy
- 152Specialties in the directoryDISTINCT · NULLEasy
- 153Completed sessions of twenty minutesArithmetic · WHEREEasy
- 154Appointment volume by dayGROUP BY · COUNTEasy
- 155Patients without a completed visitNOT EXISTSMedium
- 156Distinct visitors per doctorLEFT JOIN · COUNT DISTINCTMedium
- 157Patients visiting multiple specialtiesJOIN · HAVINGMedium
- 158Gap until the next sessionLEADMedium
- 159Busy minutes without double countingIntervals · Gaps and islands · Window frameHard
- 160Leading the specialty on multiple daysDENSE_RANK · CTE · HAVINGHard
- 161Titles under half an hourWHEREEasy
- 162Minutes watched by userSUM · GROUP BYEasy
- 163Five-star rating recordsWHEREEasy
- 164Completions on each dayCOUNT · WHEREEasy
- 165Titles waiting for a known ratingNOT EXISTSMedium
- 166Their latest opinion of a titleROW_NUMBERMedium
- 167Unique completers per categoryJOIN · COUNT DISTINCTMedium
- 168Watch and rating counts without fan-outCTE · LEFT JOINMedium
- 169Returning after a first completionCohorts · EXISTS · CTEHard
- 170Variety inside a completion streakGaps and islands · COUNT DISTINCTHard
- 171Wins on home groundWHEREEasy
- 172Draws with goalsAND · WHEREEasy
- 173Teams represented by cityCOUNT · GROUP BYEasy
- 174Played matches missing a scoreNULL · OREasy
- 175A team's complete appearance countUNION ALL · LEFT JOINMedium
- 176Teams never beaten awayEXISTS · NOT EXISTSMedium
- 177How often did these rivals meet?CASE · GROUP BYMedium
- 178The highest-scoring match each dayDENSE_RANKMedium
- 179Build the league standingsUNION ALL · Conditional aggregation · DENSE_RANKHard
- 180The first win after a losing appearanceLAG · ROW_NUMBER · CTEHard
- 181Applications still activeWHEREEasy
- 182Known scores in each roundCOUNT · GROUP BYEasy
- 183Departments with advertised jobsDISTINCTEasy
- 184Withdrawn applications per known job IDGROUP BY · WHEREEasy
- 185Applicants without an interview recordEXISTS · NOT EXISTSMedium
- 186Distinct applicants for every jobLEFT JOIN · COUNT DISTINCTMedium
- 187Latest interview attempt in each roundROW_NUMBERMedium
- 188Applying across departmentsJOIN · HAVINGMedium
- 189Top latest two-round totalsROW_NUMBER · DENSE_RANK · CTEHard
- 190The shortest ordered passing interview pairSelf join · ROW_NUMBER · CTEHard
- 191Counters needing a data checkWHEREEasy
- 192Distinct observation days by meterCOUNT DISTINCTEasy
- 193The cheapest advertised rateMIN · GROUP BYEasy
- 194Counters at one hundred or moreWHEREEasy
- 195Latest valid counter per meterROW_NUMBER · LEFT JOINMedium
- 196Meters without a usable observationNOT EXISTSMedium
- 197The valid counter did not advanceLAG · CTEMedium
- 198The last counter of the dayROW_NUMBER · SUM · JOINMedium
- 199Consumption across counter resetsLAG · CASE · CTEHard
- 200Bill usage at the effective tariffLAG · ROW_NUMBER · Effective datesHard
- 201Pledges awaiting settlementWHEREEasy
- 202The target total by categorySUM · GROUP BYEasy
- 203Campaigns supported by a backerCOUNT DISTINCTEasy
- 204Refund amounts per pledge IDSUM · GROUP BYEasy
- 205The money left in each settled pledgeCTE · LEFT JOINMedium
- 206Campaigns without a settled pledgeNOT EXISTSMedium
- 207Settled support arriving too lateJOIN · SUMMedium
- 208Backers returning to one campaignHAVING · COUNTMedium
- 209The pledge that crossed the targetRunning total · ROW_NUMBER · CTEHard
- 210A success shared by several backersCTE · HAVING · AggregationHard
- 211Papers still unmarkedIS NULLEasy
- 212A perfect scoreWHEREEasy
- 213Students in each classroomGROUP BY · COUNTEasy
- 214Score bounds by subject IDMIN · MAXEasy
- 215Attempts clearing their own pass markJOINMedium
- 216The latest paper in each subjectROW_NUMBERMedium
- 217How many students tried each subject?LEFT JOIN · COUNT DISTINCTMedium
- 218Repeated unsuccessful attemptsJOIN · HAVINGMedium
- 219Passing the entire latest report cardROW_NUMBER · Relational divisionHard
- 220The strongest overall improvementROW_NUMBER · DENSE_RANK · CTEHard
- 221Rides with a zero fareWHEREEasy
- 222At least half an hour in transitArithmetic · WHEREEasy
- 223Stops per zoneGROUP BY · COUNTEasy
- 224Trips between different known stopsWHERE · NULLEasy
- 225Arrivals and departures at every stopCTE · LEFT JOINMedium
- 226The busiest direction of the dayCOUNT · DENSE_RANKMedium
- 227A rider's daily spendGROUP BY · COALESCEMedium
- 228A direct interchange to the next tripLEAD · CTEMedium
- 229The longest connected daily journeyLAG · Gaps and islandsHard
- 230How many rides were active at once?Sweep line · UNION ALL · Running totalHard
- 231Charges still pendingWHEREEasy
- 232Negative captured adjustmentsWHERE · ANDEasy
- 233Refund records per dayCOUNT · GROUP BYEasy
- 234Cities with at least two customersHAVINGEasy
- 235The net captured chargeCTE · LEFT JOINMedium
- 236Captured charges refunded in fullJOIN · HAVINGMedium
- 237Customers with multiple refund recordsJOIN · GROUP BYMedium
- 238Refunds without a known chargeNOT EXISTSMedium
- 239The refund that exceeded the chargeRunning total · ROW_NUMBERHard
- 240A purchase after a full refundCTE · Running total · ROW_NUMBERHard
- 241Variants with an assignmentDISTINCTEasy
- 242Assignments missing a variantNULLEasy
- 243Purchases with positive revenueWHEREEasy
- 244The event-type inventoryCOUNT · GROUP BYEasy
- 245One initial variant per userROW_NUMBER · CTEMedium
- 246Users assigned to multiple variantsCOUNT DISTINCT · HAVINGMedium
- 247Purchases outside the experimentNOT EXISTS · DISTINCTMedium
- 248Revenue after initial assignmentROW_NUMBER · LEFT JOIN · SUMMedium
- 249A seven-day experiment cohort panelCohorts · CTE · Conditional aggregationHard
- 250Exposure before conversionROW_NUMBER · EXISTS · FunnelHard