practice a little every day — you've got this ♡
SQL Interview Problems
Practice 5971 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.
- 5971
- Problems
- 2211
- Auto-graded
- 15
- Topics
- 272
- Added today
Showing 91–120 of 239 results
- SQL & DataMediumAuto-gradedPremium Viewing Hours Rolled Up by Week and Month
Filter viewing events to premium subscribers, bucket them into Monday-start weeks and calendar months per user, sum minutes into hours, and return a sorted long-format result.
SQL & Dataaggregationgroup-bydateshash-map - SQL & DataMediumModel answerSingle Funnel Score for Ads from Impression and Click Logs
Design one metric that blends click-through and purchase quality, then write SQL that attributes clicks to impressions and reports it per ad for the past week.
SQL & Datasqljoinswindow-functionsmetrics - SQL & DataMediumModel answerPooled Reply Rates per Category with Wilson Intervals in pandas
Clean a job-postings table, compute invitation-weighted reply rates per category with 95% Wilson intervals, rank the top 5, and check the weighting identity numerically.
SQL & Datapandasgroupbywilson-intervaldata-cleaning - SQL & DataMediumModel answerRevenue Rollups, a 2x2 Pivot and a VIP Flag in pandas
Join two small tables in pandas, then build channel revenue totals, a member-by-channel pivot, per-state order and buyer counts, and a rule-based high-value flag.
SQL & Datapandasmergegroupbypivot_table - SQL & DataMediumModel answerCleaning Account Data in R and Selecting Top Half of Students in SQL
Clean a customer CSV with ordered null-handling rules and compute two averages in tidyverse R, then write one MySQL 8 query returning the top half of students by average grade.
SQL & Datasqlrtidyversewindow-functions - SQL & DataMediumAuto-gradedPrefix Totals by Value Across Duplicate-Heavy Records
Compute, for each record, the total of all values in the dataset that do not exceed its own value, handling ties and large inputs efficiently via grouping and a running total.
SQL & Dataaggregationprefix-sumsortinghash-map - SQL & DataMediumModel answerApproved-Profile Daily Snapshot with Country Rollup and Checks
Build a point-in-time snapshot of profiles whose latest version has an approved final review, add 7-day engagement and country rollups, and write data-quality and rerun-safety checks.
SQL & Datasqlwindow-functionspoint-in-time-snapshotdata-validation - SQL & DataMediumModel answerFlagging Heavy VR Headset Users: Streak Detection in SQL
Define a precise rule for excessive headset use, then write SQL that counts flagged users, active users, and the flagged share over a trailing 30-day window.
SQL & Datasqlgaps-and-islandswindow-functionsmetric-definition - SQL & DataMediumModel answerRank Advertisers by User Complaint Rate Over a 7-Day Window
Write SQL that finds the worst advertisers by report-to-visit rate, picks each one's worst ad, and builds a daily leaderboard without double-counting visits or reports.
SQL & Datasqlwindow-functionsaggregationjoins - SQL & DataMediumModel answerWeekly Ad Click Rate: Overall and Per Campaign Category
Write SQL that deduplicates ad event logs, restricts them to a one-week UTC window, and computes click-through rate overall and per campaign type, with safe handling of zero impressions.
SQL & Datasqlaggregationdeduplicationconditional-aggregation - SQL & DataEasyAuto-gradedSum Open Credit Balances per Customer, Sorted by ID
Filter records by a status value, total a numeric field per customer ID, and return the results sorted by ID, mirroring a SQL filter, group and order query in Python.
SQL & Datahash-mapaggregationgroup-bysorting - SQL & DataMediumAuto-gradedPick the Title Winner from Mixed-Orientation Game Records
Given team and game record lists, find the 2023 championship winner when the winner may be on either side, with a deterministic highest-score tie-break.
SQL & Datadata-manipulationjoinsfilteringhash-map - SQL & DataMediumAuto-gradedDaily Tally of Users Who Posted on Their Signup Day
Given user and post records with timestamps, count per signup date how many users published at least one post that same calendar day, counting each user once.
SQL & Datahash-mapdatesdedupaggregation - SQL & DataHardModel answerTableau Blend vs Join: Targets Against Sales Walkthrough
Work out exact join and blend results on two small tables, then explain how filter order, fan-out and granularity change the numbers and when blending is the better choice.
SQL & Datatableaudata-blendingjoinsorder-of-operations - SQL & DataEasyModel answerWhy a Garden Mulch Report Loses Its Non-Promo Days
Diagnose a multi-join SQL report that undercounts mulch sales, trace the lost rows step by step, and rewrite it to return all 30 days with correct totals.
SQL & Datasqlleft-joinwhere-vs-ondate-spine - SQL & DataMediumAuto-gradedLive Stream Creator Stats: Weekly, Monthly Rankings and Daily Check
Join two record lists on a composite key with missing-row defaults, then compute a filtered distinct count, a per-group top-5 ranking with tie-breaks, and an every-item condition check.
SQL & Datajoinsgroup-byrankingtie-breaking - SQL & DataMediumModel answerWhy Does This Hive INSERT...SELECT Fail or Load Bad Data?
Diagnose a failing Hive INSERT...SELECT into a partitioned ACID ORC table and explain, in order, the fixes for syntax, alignment, casts, partitions, settings and format.
SQL & Datahiveinsert-selectdynamic-partitionstype-casting - SQL & DataMediumAuto-gradedTop Two Spending Categories per Shopper with Share of Spend
Aggregate line-item spend by shopper and category, rank with ties, keep the top two ranks, add spend share, and handle shoppers with no purchases.
SQL & Dataaggregationgroupingrankingjoins - SQL & DataMediumModel answerBest Video Category by Mean Watch Time in pandas
Compute which category has the highest mean watch time across valid video rows, with null and nonpositive filtering, name lookup, lexicographic tie-breaks, and rounding.
SQL & Datapandasaggregationhash-mapdata-cleaning - SQL & DataMediumModel answerStaggered-Rollout Panel and Weekly Rollup in SQL
Write warehouse SQL that turns daily participation logs into a treatment-aware employee-day panel and a site-week participation table for a staggered-rollout DiD analysis.
SQL & Datasqldifference-in-differencespanel-dataleft-join - SQL & DataMediumModel answerHow a Three-Column MySQL Index Serves Different Queries
Analyze how one composite InnoDB index handles three query shapes, covering leftmost-prefix seeks, ordering, range limits, index condition pushdown, and the cost of row lookups.
SQL & Datamysqlinnodbcomposite-indexcovering-index - SQL & DataEasyAuto-gradedCreator Reach Score and Monthly New-Follower Trends
Join and aggregate social-graph records to compute per-user reach scores and per-month follower statistics, including previous-month lookups, growth rates and running totals.
SQL & Dataaggregationjoinswindow-functionshash-map - SQL & DataMediumModel answerQuarterly Take-Home Pay and Latest-Period Drop Report
Write a query that totals each employee's first-quarter take-home pay and flags those whose most recent paycheck fell below the one before it, with the percentage drop.
SQL & Datasqlwindow-functionsaggregationcte - SQL & DataEasyModel answerSeries vs DataFrame, WHERE vs HAVING, and Finding Repeated Emails
Three short data-engineering questions: contrast pandas Series and DataFrame, explain when SQL applies WHERE versus HAVING, and write a query that reports emails occurring more than once.
SQL & Datasqlpandasgroup-byhaving - SQL & DataEasyAuto-gradedCurrent Top Earner in Each Department
Reduce salary history to each person's current pay per department, then choose the highest-paid person in each department, with exact tie and ordering rules.
SQL & Datagroupinghash-mapdata-manipulationtop-n-per-group - SQL & DataMediumModel answerDaily New, Retained and Churned Devices by Platform
Write one SQL query that classifies devices as new, retained or churned for 2025-09-01 from a raw event log, and reports net growth overall and per platform.
SQL & Datasqlcteretentiondeduplication - SQL & DataMediumAuto-gradedDaily Leading Buyers Among Active Subscribers
Filter orders by inclusive membership windows, total quantities per day and customer, and return every customer tied for each day's maximum, in sorted order.
SQL & Dataaggregationgroup-bytiesdate-range-filter - SQL & DataMediumAuto-gradedCoupon Campaign Conversion and 48-Hour Spend Report
Build a per-user cohort from coupon events, then join transactions by time window to compute cohort size, converters, and spend within 48 hours.
SQL & Datajoinshash-mapdatetimeaggregation - SQL & DataMediumAuto-gradedTally Faulty and Clean Submissions per Company
Aggregate two conditional counts per group from two related row lists, keeping groups with no matching rows and handling both boolean and string status values.
SQL & Dataconditional-aggregationleft-joinhash-mapgroup-by - SQL & DataEasyAuto-gradedSessionize Clickstream Events with a 30-Minute Inactivity Gap
Deduplicate retried events, split each user's activity into sessions on gaps over 30 minutes, and summarize each session with its start, end and distinct page count.
SQL & Datasessionizationwindow-functionsdeduplicationgaps-and-islands