practice a little every day — you've got this ♡
SQL Interview Problems
Practice 5965 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.
- 5965
- Problems
- 2208
- Auto-graded
- 15
- Topics
- 271
- Added today
Showing 1–30 of 239 results
- SQL & DataMediumModel answerLast-Touch Ad Attribution: Daily Campaign Conversion Report
Write a SQL query that credits each conversion to the latest eligible ad impression within a 7-day lookback, then reports daily campaign metrics for January 2024.
SQL & Datasqlwindow-functionsattributionjoins - SQL & DataMediumModel answerCalculate Current Item Inventory from Movements and Baselines
Compute up-to-date item stock by merging starting snapshot balances with subsequent movement logs using SQL aggregations and joins.
SQL & Datasqlaggregationjoins - SQL & DataMediumModel answerSet Operations, Top-N Windows and SCD2 for Sensor Data
Compare UNION and UNION ALL, write a NULL-safe anti-join and a top-3-per-group query, then explain star-schema roles and Type 2 history tracking for a sensor dimension.
SQL & Datasqlwindow-functionsdata-warehousescd-type-2 - SQL & DataMediumAuto-gradedConsolidate E-Commerce Orders into Fact Records
Process and aggregate relational records across multiple entity tables into a single denormalized fact dataset.
SQL & Datasqlarraysdata-manipulationhash-map - SQL & DataMediumModel answerMonthly USD revenue pivot with as-of FX rate lookups
Convert multi-currency sales to USD with an as-of rate join, pivot revenue by category and region, find August's top customer per region, and flag missing FX rates.
SQL & Datasqlas-of-joinpivotwindow-functions - SQL & DataEasyAuto-gradedMonth-over-Month Revenue Change per Store
Group order records by store and calendar month, then compute each month's percentage change versus the store's previous active month, handling zero totals and gaps.
SQL & Dataaggregationgroup-bywindow-functionsdictionaries - SQL & DataEasyAuto-gradedContent Flagging System Metrics and Abuse Analysis
Process moderation report logs to calculate unique report ratios and aggregate key reporting metrics per reporter.
SQL & Dataarraysdictionariesdata-processingmetrics - SQL & DataMediumModel answerPoint-in-Time User Features and 30-Day Purchase Label in SQL
Build a leakage-free training table at a fixed snapshot: deduplicated, arrival-aware 7-day activity features per user, plus a forward-looking 30-day purchase label.
SQL & Datasqlfeature-engineeringpoint-in-timededuplication - SQL & DataMediumAuto-gradedDaily Active Users, New-User Cohorts and Next-Day Return Rate
Build a fixed 7-day report of active users, first-activity cohorts, next-day return rate and revenue per active user from raw logs, with bot filtering and deduplication.
SQL & Datacohort-analysisretentiondeduplicationhash-sets - SQL & DataMediumAuto-gradedTop Earners per Department with Ties
Given department and employee tables as lists, return every employee who earns the maximum salary in their department, keeping ties and handling duplicate names.
SQL & Datagroup-byhash-maptiesjoins - SQL & DataMediumModel answerReferral funnel SQL: LEFT JOIN date windows and country filters
Write five SQL queries over users, referrals and orders that measure referral conversion and revenue without losing zero-activity rows, with no window functions.
SQL & Datasqlleft-joingroup-byhaving - SQL & DataMediumAuto-gradedRetail Reports: Product Revenue Stats and Regional Customer Ranks
Emulate SQL-style reporting in Python: grouped mean and population stddev, NULL-to-zero mapping, inner joins across three tables, and RANK/DENSE_RANK within partitions.
SQL & Datasqlgroup-byjoinswindow-functions - SQL & DataMediumModel answerCampaign Profit by Segment and Gala Seat Filling in SQL
Build per-campaign, per-segment fundraising metrics for August 2025 with fan-out-safe joins and cost allocation, pick the more profitable campaign, then choose extra gala invitees.
SQL & Datasqlaggregationjoinswindow-functions - SQL & DataMediumModel answerBest Click Rate Day and Peak ISO Week in an Ad Log Using Pivots
Use Excel helper columns and PivotTables to find the day with the highest clicks per watch-minute and the ISO week with the most watch time, with deterministic tie-breaks.
SQL & Dataexcelpivot-tableiso-weekratio-metrics - SQL & DataMediumModel answerRolling Spend View, Dependent Inserts, and Price Change Fallout
Build a 7-day spend view over three tables, add rows in foreign-key order, update statuses and prices, then reason about how a price change distorts past spend.
SQL & Datasqlviewsleft-joininsert-update - SQL & DataMediumModel answerTrial Conversion and Day-30 Return Rates per Experiment Arm
Write one SQL query comparing control and treatment on 7-day trial conversion and on a week-long return window starting 30 days after the trial begins.
SQL & Datasqlab-testingcohort-analysisretention - SQL & DataEasyAuto-gradedName the Anomaly in an Interleaved Two-Transaction Schedule
Identify which classic concurrency anomaly a fixed read/read/write/write schedule on one shared value produces, and return the matching option letter.
SQL & Datatransactionsconcurrencyisolation-levelsserializability - SQL & DataEasyAuto-gradedSponsors Active in Both Opening Weeks
Given a log of ad submission rows, find the sponsors with at least one submission in week 1 and at least one in week 2, returned sorted, which tests set intersection and deduplication.
SQL & Datasetsdeduplicationintersectiondata-manipulation - SQL & DataMediumModel answerFiltering Merchants by Chargeback Rate: Row vs Group Filters
Find merchants whose 30-day chargeback rate exceeds 0.5% and explain why the rate filter belongs after grouping, plus dialect quirks and performance implications.
SQL & Datasqlgroup-byhavingaggregation - SQL & DataMediumModel answerPandas Activity Metrics: Local Dates, Rolling Windows, Retention
Build daily active users, rolling averages, per-user rolling counts and week-over-week retention from a UTC event log, using timezone-correct, vectorized Pandas.
SQL & Datapandastime-seriesgroupbyrolling-window - SQL & DataEasyAuto-gradedUsers Logging In Successfully From Several Countries
Group login records by user, keep only exact-match successful ones, and report users whose successful logins span at least two distinct countries, sorted.
SQL & Datahash-mapsetsfilteringgroup-by - SQL & DataMediumModel answerFlatten Event Logs and Build User Segments in pandas
Turn a table of nested event lists and attribute dicts into a flat event table, per-user features, and segment conversion rates using pandas without row loops.
SQL & Datapandasdata-manipulationexplodegroupby - SQL & DataMediumAuto-gradedBest-Scoring Enrollee for Each Academic Department
Pick one top student per department from two record lists, using GPA with deterministic tie-breaks, skipping missing values, and keeping departments that have no eligible student.
SQL & Datagroup-wise selectionleft jointie-breakingnull handling - SQL & DataMediumAuto-gradedMonthly Line Output Report with Running Totals and Defect Percent
Group daily production records by line and month, add a per-line running total, and compute each month's defect percentage from summed counts.
SQL & Datagroup-byhashingrunning-totalaggregation - SQL & DataEasyAuto-gradedUnify Two Yearly Sales Record Lists With a Mismatched Key
Tests normalizing records from two sources with a misspelled field name, casting a numeric field to float, and concatenating the lists in order without mutating inputs.
SQL & Datadata-cleaningdictionariesschema-alignmentconcatenation - SQL & DataMediumAuto-gradedFind Riders Idle Through the Latest Week of Activity
Given user and ride records, return users with no ride in the 7-day window ending at the latest ride date, including users who never rode, sorted by user_id.
SQL & Dataanti-joindate-windowhash-setfiltering - SQL & DataMediumModel answerCalculate Top Customer Revenue Share and 7-Day Growth by Product Model
Write a SQL query to compute 7-day revenue growth and identify top spenders per product model with tie-breaking logic based on historical purchase date.
SQL & Datasqlwindow-functionsaggregationsjoins - SQL & DataMediumAuto-gradedWeekly Totals with 3-Week Rolling Sum in Pacific Time
Bucket timestamped payments into Pacific-time Monday weeks, fill empty weeks with zero, and report weekly and trailing three-week totals.
SQL & Datatime zonesdate bucketingrolling windowaggregation - SQL & DataMediumModel answerRating Trends Across a Rider's First and Third Months by City
Write a PostgreSQL query returning, per city, the mean per-ride rating in each rider's first and third months with rides, handling skipped months, unrated rides and weighting.
SQL & Datasqlpostgresqlwindow-functionsdense-rank - SQL & DataHardModel answerDaily KPI Pipeline and Retention Cohorts in SQL
Write SQL for a photo app: totals, top month, top followed user, daily KPI and follower-bucket tables in Los Angeles time, and week-1 retention cohorts.
SQL & Datasqlwindow-functionstimezonescohort-retention