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 139 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 - SQL & DataMediumModel answerBuild a Pandas Pipeline for Portfolio Returns and Risk Metrics
Design a pandas workflow that cleans price CSVs, builds portfolio returns under several rebalancing rules, and reports return, risk, Sharpe and drawdown metrics for multiple portfolios.
SQL & Datapandastime-seriesportfolio-analyticsdata-cleaning - SQL & DataMediumModel answerFeature Activation, Time-to-First-Purchase, and Region Switching in SQL
Write SQL over users and transactions for regional activation and purchase rates, first-purchase latency with percentiles, and flagging purchases made outside a user's first-purchase region.
SQL & Datasqlwindow-functionspercentilescohort-metrics - SQL & DataMediumModel answerMonthly Channel Cohorts: Measuring First-Month Account Usage
Write a SQL report of how many new banking users make three or more completed debits totaling at least $50 in their first 30 days, grouped by signup month and channel, excluding immature cohorts.
SQL & Datasqlcohort-analysisleft-joinconditional-aggregation - SQL & DataMediumModel answerQuarterly Revenue Query and Largest-File Shell Script
Write a SQL query that totals 2023 sales by quarter, and a robust bash script that finds the largest file under a directory, handling odd filenames and error cases.
SQL & Datasqlaggregationgroup-bybash - SQL & DataMediumModel answerRolling ETA median, DiD and CUPED uplift on ride-request data
Build a gap-free daily city series with a 7-day rolling median ETA and conversion in PostgreSQL, then estimate uplift with city-level DiD and a CUPED-adjusted, cluster-robust estimate in Python.
SQL & Datapostgresqlwindow-functionsdate-spinedifference-in-differences - SQL & DataMediumModel answerUser Spend Tiers in Pandas and Daily Platform Conversion in SQL
Build a per-user revenue and distinct-purchase table with tiers in Pandas, then write SQL for daily purchase-to-click conversion by platform over the last 30 days.
SQL & Datapandasgroupbysqlconditional-aggregation - SQL & DataHardModel answerAnalyzing Noisy A/B Experiment Metrics and SRM in SQL
Write SQL queries to censor crossover exposures, compute 14-day conversion metrics under blackout constraints, and calculate an SRM chi-square p-value.
SQL & DataSQLA/B TestingExperimentationWindow Functions - SQL & DataMediumModel answerRolling Cold-Food Delivery Metric Calculation in PostgreSQL
Write PostgreSQL queries to flag cold food deliveries, calculate daily and rolling 7-day cold delivery rates, rank restaurants, and detect courier quality outliers with z-scores.
SQL & Datasqlwindow-functionsaggregationscte - SQL & DataMediumModel answerPower Sellers and Vehicle Share of New US Listing Engagement
Two SQL tasks on a marketplace: count sellers with many well-engaged products in a short window, and compute the Vehicle share of interactions on newly created US listings.
SQL & Datasqljoinsaggregationsnapshot-tables - SQL & DataMediumModel answerRadiology Claims Spend Summary with Fiscal-Month Mapping in pandas
Clean a small claims CSV in pandas: sum spend per procedure group, compute each group's share of the total, and derive an October-based fiscal month without row loops.
SQL & Datapandasdata-cleaninggroupbydatetime - SQL & DataMediumModel answerLeveraging AI Assistance Responsibly in SQL Collaborative Coding
Learn how to conduct an AI-assisted SQL pair-programming session while demonstrating clear reasoning, strict data safety, step-by-step query construction, and rigorous verification.
SQL & DataSQLPair ProgrammingAI Coding ToolsCode Quality - SQL & DataMediumModel answerSeven-Day Return Rate from a Daily Posting Log
From a per-day post count table, find each user's first active date, their first-week post total, and the share of users who were active on the seventh day of their life on the platform.
SQL & Datasqlwindow-functionsretentioncohort-analysis - SQL & DataMediumModel answerGap Between a User's Two Latest Views of the Same Ad
Write one SQL query returning, per user and ad with at least two views, the newest and second-newest timestamps plus the gap between them in seconds.
SQL & Datasqlwindow-functionsrow-numbertimestamp-arithmetic - SQL & DataMediumModel answerSeller Enforcement Timeline and Repeat-Buyer Product Filters
Three SQL/pandas tasks: find sellers penalized after a reinstatement, get the first event after the latest reinstatement, and find customers who bought A in 2010 and B in 2018.
SQL & Datasqlwindow-functionsconditional-aggregationpandas