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 61–90 of 239 results
Compute 7-day retention rates across user subscription plans using PostgreSQL, handling distinct user counts, edge cases, and four-decimal precision.
Model answersqlpostgresqlaggregationsjoinsRework a monthly new-customer and year-over-year report so companies listed in a free-plan table vanish from every month, using a duplicate-safe anti-join applied before aggregation.
Model answersqlanti-joinnot-existscteWrite a single SQL query that builds a month-by-country report covering signups, 7-day conversion, day-7 retention, valid GMV, and last-touch top campaign, with dedup and UTC handling.
Model answersqlcohort-analysisretentionwindow-functionsJoin logins, users and transfers to flag logins from a new device or IP that are followed within two hours by a large transfer to a first-time recipient.
Auto-gradeddata-manipulationtime-windowsjoinsfraud-detectionWrite SQL to aggregate defaults and accounts over a trailing 12-month window for each customer segment, correctly handling non-consecutive dates and zero division.
Model answersqlwindow-functionstime-seriesaggregationReplace NaNs in numeric DataFrame columns with column means, then extend it to in-place updates, per-group means and all-NaN columns, with non-numeric columns left alone.
Model answerpandasmissing-dataimputationgroupbyWrite a SQL query that reports, per UTC day and ad origin, how many ads were active and how much revenue those ads earned on days they were active.
Model answersqljoinsaggregationfan-outDeduplicate employee records across regions, convert local salaries to USD using historical exchange rates, and rank the top earners.
Auto-gradeddata-manipulationhash-mapsortingsqlWrite an efficient SQL query to aggregate quarterly activity and overall yearly stats per cryptocurrency, preserving coins with zero transactions.
Model answersqlaggregationjoinspivotingUse deduplicated user-document pairs to analyze how collaborators arrive, who works most with a given user, and which country has the highest share of users who collaborate.
Model answersqlpandasself-joindeduplicationProcess crowd-sourced label data to compute consensus metrics and flag underperforming annotators at scale.
Model answerpandasdata-cleaningdata-analysisgroup-byAggregate ticket revenue and shares, then compute average distinct in-period visits per annual-pass period, including zero-visit passes, to project total entries.
Auto-gradedaggregationjoinsdate-range-filteringhash-mapWrite SQL that labels each view by the moderation decision known at view time and by the final decision, computes daily prevalence per country, and ranks the top creators by violating share.
Model answersqlwindow-functionsas-of-joinlateral-joinWrite a query that gives each device's total replies over the current day and the six days before it, handling duplicate rows and missing dates correctly.
Model answersqlwindow-functionstime-seriespandasWrite two SQL queries over daily call and profile tables: the share of French users on a call yesterday, and total U.S. call time divided by the number of U.S. daily-active users today.
Model answersqljoinsaggregationdeduplicationAggregate per-courier earnings for a pay period from a paginated, time-zoned event feed, handling corrections, cancellations, and rounding, with itemized totals.
Model answerpythondata-aggregationpaginationtimezonesProcess monthly user subscription snapshots to compute customer churn rate, gross revenue churn, and net revenue retention metrics.
Auto-gradeddata-manipulationaggregationssaas-metricssqlProcess call records and lifecycle logs to compute the success rate of answered calls for eligible users within a specific time frame.
Auto-gradedsqlarrayshash-tableExplain how DELETE and TRUNCATE differ, when a view beats a stored table, and how a CROSS JOIN builds full combination grids, using a small employee and department schema.
Model answersqldelete-vs-truncateviewscross-joinWrite two SQL queries on a call-log table: rank the ten users who placed the most calls in the past week, and compute the share of yesterday's French users who joined a video call.
Model answersqlaggregationdate-filteringconditional-aggregationFilter invalid responses, categorize users by signup tenure, and aggregate satisfaction metrics by region and cohort.
Auto-gradeddata manipulationaggregationgroupingfilteringAggregate relational records over a specific date window to identify peak entities with tie preservation at multiple hierarchical levels.
Auto-gradedarrayshash-tablesortingdate-parsingEvaluate A/B experiment unique CTR using windowed SQL deduplication and analyze model precision-recall performance with weighted sample thresholds in Python.
Model answerSQLWindow FunctionsPandasPrecision-RecallCompute top venue locations by summing vote weights using SQL and Python, while handling missing values, text normalization, and ties.
Model answerSQLPythonData CleaningAggregationAggregate weekly revenue in SQL using ISO weeks, calculate period-over-period performance, and attribute regional drop drivers with guardrails against incomplete weeks.
Model answersqltime-seriesaggregationwindow-functionsClean a click-stream with pandas to compute daily banner CTR without bots or accidental clicks, user-level CTR by signup cohort, and per-user session-length change around a feature launch.
Model answerpandasmerge_asofsessionizationctrArchitect an end-to-end data warehouse for high-throughput event logs, detailing schema design, idempotent deduplication, metric modeling, and performance optimization.
Model answerdata-warehousingschema-designsqlevent-dataImplement an iterative nested list flattener in Python with edge-case handling, and construct a SQL query to compute Daily Active Users (DAU) using strict UTC date casting.
Model answerpythonsqlstacks-queuesdata-manipulationFilter call records by start time, group by user to get average duration in minutes, then rank with a deterministic tie-break and keep the top 10.
Auto-gradedgroup-byaggregationdatetimesortingSolve multi-part SQL analytics queries covering sparse dimensions, gap-and-island sequences, conversion metrics, and latency percentiles.
Model answersqlwindow-functionsgaps-and-islandspercentiles