Topic
SQL & Data interview problems
Joins, window functions, aggregation and data cleaning in Python. 239 original problems, each with hidden test cases you can run in the browser.
27 easy200 medium12 hard
Showing 31–60 of 239 results
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.
Model answerpandastime-seriesportfolio-analyticsdata-cleaningFind each user's earliest-watched title, then pick the title that opens the most users' histories, using deterministic tie-breaking rules.
Auto-gradedhash-mapaggregationtie-breakinggroup-byJoin two tables as lists, filter on a strict rating threshold with missing values, and compute a per-group minimum with a default of 0 and sorted output.
Auto-gradedaggregationleft-joinnull-handlinggroup-byFilter users by total event count, then rank each user's payments within each calendar day by amount using competition ranking (ties share a rank, then a gap).
Auto-gradedwindow-functionsgroupingrankingsortingWrite 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.
Model answersqlwindow-functionspercentilescohort-metricsGroup users into signup-date cohorts and count who was active exactly 30 days later, using sets and date arithmetic with careful handling of duplicates.
Auto-gradedhash-setdate-arithmeticaggregationcohort-analysisFilter records to one month, group by key, apply a minimum-count threshold, compute a rounded average, and return the top three groups, mirroring a SQL WHERE/GROUP BY/HAVING/ORDER BY/LIMIT pipeline.
Auto-gradedaggregationhash-mapgroup-bysortingWrite 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.
Model answersqlcohort-analysisleft-joinconditional-aggregationWrite 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.
Model answersqlaggregationgroup-bybashAggregate user log data to calculate distinct active users per country in 2023, then return the 3 least active countries.
Auto-gradedarrayshash-tablesortingaggregationBuild 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.
Model answerpostgresqlwindow-functionsdate-spinedifference-in-differencesBuild 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.
Model answerpandasgroupbysqlconditional-aggregationWrite SQL queries to censor crossover exposures, compute 14-day conversion metrics under blackout constraints, and calculate an SRM chi-square p-value.
Model answerSQLA/B TestingExperimentationWindow FunctionsTests table-style aggregation in Python: select the row with the highest key, count occurrences per key, and handle null or missing sponsor references with a default of zero.
Auto-gradedaggregationhash-mapnull-handlingjoinsWrite 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.
Model answersqlwindow-functionsaggregationscteTwo 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.
Model answersqljoinsaggregationsnapshot-tablesClean 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.
Model answerpandasdata-cleaninggroupbydatetimeDeduplicate late-arriving trade versions, filter by status, window and KYC, then aggregate per account and day into exposure, utilization and breach figures.
Auto-gradeddata-manipulationdeduplicationaggregationjoinsFind the Nth highest unique value in a list of integers, returning None if N is out of valid bounds.
Auto-gradedarrayssortingsqlLearn 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.
Model answerSQLPair ProgrammingAI Coding ToolsCode QualityFrom 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.
Model answersqlwindow-functionsretentioncohort-analysisProcess minute-level streaming activity and viewer events to calculate time-series metrics, category shares, month-over-month growth, and joined yearly summaries.
Auto-gradeddata-aggregationtime-seriesjoinsanalyticsWrite 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.
Model answersqlwindow-functionsrow-numbertimestamp-arithmeticThree 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.
Model answersqlwindow-functionsconditional-aggregationpandasAnalyze video engagement and interaction rates segmented by viewer relationship types over a rolling 7-day window using SQL aggregations and joins.
Model answersqlaggregationjoinsAggregate two event tables over a 30-day window, fill missing rows with zeros, and compute safe-division shares and revenue-per-conversion per day and destination.
Auto-gradedaggregationhash-mapdate-windowdata-manipulationDefine launch success for a new paid tier using only transaction and activity tables, then design a rule-based SQL alerting system for suspicious payments.
Model answerproduct-analyticscohort-retentionsql-window-functionsfraud-rulesExplain how to build a robust, idempotent daily incremental ingestion workflow that handles duplicates, backfills, and schema validation on large relational tables.
Model answerdata-engineeringsqletldata-pipelinesDefine usage growth metrics and write SQL to analyze monthly active users, new user acquisition, and discrete monthly revenue for custom app themes.
Model answersqltime-seriesaggregationwindow-functionsWrite SQL to find each country's top-impression category and the share of weekly active users who were active on 4+ days and used 3+ distinct features on a single day.
Model answersqlwindow-functionsaggregationcte