KatInterview

practice a little every day — you've got this ♡

SQL & Data 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 151–180 of 239 results

  • SQL & DataMediumModel answer
    Schema Design for a Video Streaming Service

    Design a relational database schema for a large-scale video platform, addressing scalability, GDPR compliance, and analytics requirements.

    SQL & Datadatabase-designschema-modelingindexingpartitioning
  • SQL & DataMediumModel answer
    Rolling Week Averages with Calendar-Based Windows

    Calculate a 7-day moving average for each date using calendar intervals, not row counts, handling gaps and NULL values correctly.

    SQL & Datawindow-functionsdate-arithmeticaggregation
  • SQL & DataMediumModel answer
    Hourly Click-Through Rate and Local Revenue by Country

    Calculate hourly CTR and currency-adjusted revenue per country from event logs, joining latest exchange rates and handling time bucketing and safe division.

    SQL & Dataaggregationjoinswindow-functionsdate-time
  • SQL & DataMediumModel answer
    Daily and Category-Level New Customer Purchase Rate

    Flag each order as a customer's first in a category or overall, then aggregate to compute new-buyer proportions by day and category.

    SQL & Datasqlpandaswindow-functionsaggregation
  • SQL & DataHardModel answer
    Reconstruct the Latest State of Every Listing

    Query an event-log table to produce one row per listing showing its most recent status and total lifespan in hours.

    SQL & Datawindow-functionsaggregationtimestamp-arithmetic
  • SQL & DataMediumAuto-graded
    Aggregate Transactions by Country for Most Recent Active Period

    Tests date handling, filtering, and grouped aggregation to find the latest month with successful records and summarize by region.

    SQL & Dataaggregationdate-manipulationfiltering
  • SQL & DataMediumAuto-graded
    User Signup and Follower Metrics Report

    Simulate three SQL analytics queries in Python: total users, busiest signup month (with tie-break), and the most-followed usernames including ties.

    SQL & Dataaggregationgroupingcountingties
  • SQL & DataMediumAuto-graded
    Weekly Cohort Activity Retention Analysis

    Group users by signup week, compute seven-day activity retention rates, and handle zero-retention cohorts correctly.

    SQL & Datadata-analysiscohort-analysisretentionaggregation
  • SQL & DataHardModel answer
    Multi-Stage Funnel Analysis in SQL: Windows, Dedup & Rollups

    Write ANSI-SQL to build a windowed conversion funnel, attribute acquisition channels, flag bot-like campaigns, deduplicate near-duplicate events, and compute rolling unique viewers.

    SQL & Datafunnel-analysiswindow-functionsCTEsdeduplication
  • SQL & DataMediumModel answer
    Daily Funnel Metrics and 1-Day Retention in SQL and pandas

    Build a validated event layer, then compute daily funnel counts, per-user first-event dates, and a one-day retention rate using SQL and pandas.

    SQL & Datasqlpandasfunnelretention
  • SQL & DataMediumModel answer
    Window Ranking Functions: Choosing the Right One for Top-N Queries

    Explain how ROW_NUMBER, RANK, and DENSE_RANK behave differently when ties exist, and which to use depending on what "top N" actually means.

    SQL & Datawindow-functionsrankingtiestop-k
  • SQL & DataMediumModel answer
    Predicting the Output of a Join + Aggregate + Window Query

    Read a multi-clause SQL query against two small tables and state exactly which rows come back, with each column value, traced stage by stage.

    SQL & Datasqljoinswindow-functionsnulls
  • SQL & DataMediumModel answer
    Campaign Attribution: Define Metrics and Write SQL for Purchase Impact

    Design attributable, time-bounded conversion metrics for a marketing campaign and implement the SQL to measure, baseline, and diagnose them across a five-table schema.

    SQL & Datasqlmetricsattributionwindow-functions
  • SQL & DataMediumModel answer
    SQL Window Functions, Join Cardinalities, Dedup, and Pandas Merges

    Work through ten interconnected SQL and pandas tasks spanning aggregations with NULL handling, join types, set operations, window functions, views, duplicate management, and indexing strategy.

    SQL & Datasqlpandaswindow-functions
  • SQL & DataMediumModel answer
    Cohort Engagement Metrics for Single-Category Users

    Filter users into mutually exclusive content-type cohorts, then compute activity counts, median active days, a 10-day threshold rate, and per-user average minutes.

    SQL & Datacohort-analysisaggregationwindow-functionsdata-quality
  • SQL & DataMediumAuto-graded
    Classify Risky Transactions and Dispute History

    Tests multi-window aggregation, business-rule encoding, and precise date/time boundary handling across three related data tables.

    SQL & Datadata-manipulationdatetimebusiness-rules
  • SQL & DataMediumAuto-graded
    Conditional Sum Aggregation with Group Filtering

    Compute filtered totals two ways and group-then-threshold results, mirroring SQL conditional aggregation semantics.

    SQL & Dataconditional-aggregationgroupingsimulationpython
  • SQL & DataMediumModel answer
    Payment Risk Scoring with Rolling Windows and NULL Handling in SQL

    Analyze a payments table to rank users by declined volume, flag burst activity in 24-hour windows, and classify each transaction by amount using conditional logic.

    SQL & Datawindow-functionsaggregationcase-whennull-handling
  • SQL & DataMediumModel answer
    SQL Window Functions, Join Types, and Python Aggregation

    Demonstrate SQL window functions, join semantics, ranking functions, string aggregation, and Python dict-based accumulation over transactional row data.

    SQL & Datawindow-functionsjoinsaggregationpython
  • SQL & DataMediumModel answer
    Compare Acquisition Channels by Spend, Retention, and Early Revenue

    Write SQL to profile marketing channels across four dimensions: user counts, top spenders, cohort retention, and 90-day ARPU.

    SQL & Datawindow-functionscohort-analysisaggregationjoins
  • SQL & DataMediumModel answer
    Validate and Aggregate Subscription Event Data

    Profile a subscription events table to verify data integrity, then compute the earliest active date and most recent inactive date per subscription.

    SQL & Datasqlpandasdata-validationtime-series
  • SQL & DataMediumModel answer
    Quarter-over-Quarter Revenue Analysis with Same-Store Metrics

    Build a SQL query that compares quarterly performance across different time periods, handling store openings/closings and computing both total and same-store growth rates.

    SQL & Datasqlaggregationtime-seriesanalytics
  • SQL & DataMediumAuto-graded
    Reconcile Ledger and Bank Snapshots for a Month

    Join two per-month balance datasets on account id, classify each account as match, mismatch, or missing on one side, handling true zero balances correctly.

    SQL & Datahashingjoindata-manipulationedge-cases
  • SQL & DataMediumModel answer
    Per-Category Top-10 Items: Revenue Share Analysis

    Write a SQL query ranking the top 10 items by revenue within each category and compute what fraction of each category's total revenue those items represent.

    SQL & Datawindow-functionsaggregationCTEsranking
  • SQL & DataMediumModel answer
    Time-Zone-Aware Activity Drop Detection Query

    Write SQL to find countries where the most creators posted significantly less in the recent week than their baseline, accounting for local time zones.

    SQL & Datasqlwindow-functionstime-seriesaggregation
  • SQL & DataMediumAuto-graded
    Distinct Content Categories per Reader

    Tests two-level aggregation: counting distinct content categories per reader on a target date, then bucketing those counts into a frequency histogram across all dates.

    SQL & Datagroupingaggregationhistogramhashing
  • SQL & DataMediumModel answer
    SQL Analysis and Statistical Testing of App Usage Patterns

    Write SQL queries to identify top apps and compute category distributions, then design a statistical test to compare engagement frequency across user segments.

    SQL & Datasqlaggregationwindow-functionsstatistical-testing
  • SQL & DataEasyModel answer
    Highest Spender in the Company's First Decade

    Identify which user spent the most money during the initial ten-year period starting from the company's very first transaction.

    SQL & Datasqlaggregationwindow-functionsdate-filtering
  • SQL & DataMediumModel answer
    Fix a Promotion Join That Silently Drops Sales Rows

    Diagnose and repair a multi-table SQL query that loses rows due to a NULL-breaking join, UTC date bucketing, and promotion fan-out inflation.

    SQL & Datajoinsdatetimewindow-functionsdebugging
  • SQL & DataMediumModel answer
    Rolling Window Metrics for Digital Ad Campaign Data

    Compute impression rankings, conversion rates by format, per-user revenue, and peak traffic hours from ad event tables using SQL aggregation and joins.

    SQL & Datasqlaggregationjoinswindow-functions