KatInterview

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

SQL & Data Interview Problems

Practice 5969 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.

5969
Problems
2211
Auto-graded
15
Topics
273
Added today

Showing 61–90 of 139 results

  • SQL & DataMediumModel answer
    Cleaning Account Data in R and Selecting Top Half of Students in SQL

    Clean a customer CSV with ordered null-handling rules and compute two averages in tidyverse R, then write one MySQL 8 query returning the top half of students by average grade.

    SQL & Datasqlrtidyversewindow-functions
  • SQL & DataMediumModel answer
    Approved-Profile Daily Snapshot with Country Rollup and Checks

    Build a point-in-time snapshot of profiles whose latest version has an approved final review, add 7-day engagement and country rollups, and write data-quality and rerun-safety checks.

    SQL & Datasqlwindow-functionspoint-in-time-snapshotdata-validation
  • SQL & DataMediumModel answer
    Flagging Heavy VR Headset Users: Streak Detection in SQL

    Define a precise rule for excessive headset use, then write SQL that counts flagged users, active users, and the flagged share over a trailing 30-day window.

    SQL & Datasqlgaps-and-islandswindow-functionsmetric-definition
  • SQL & DataMediumModel answer
    Rank Advertisers by User Complaint Rate Over a 7-Day Window

    Write SQL that finds the worst advertisers by report-to-visit rate, picks each one's worst ad, and builds a daily leaderboard without double-counting visits or reports.

    SQL & Datasqlwindow-functionsaggregationjoins
  • SQL & DataMediumModel answer
    Weekly Ad Click Rate: Overall and Per Campaign Category

    Write SQL that deduplicates ad event logs, restricts them to a one-week UTC window, and computes click-through rate overall and per campaign type, with safe handling of zero impressions.

    SQL & Datasqlaggregationdeduplicationconditional-aggregation
  • SQL & DataHardModel answer
    Tableau Blend vs Join: Targets Against Sales Walkthrough

    Work out exact join and blend results on two small tables, then explain how filter order, fan-out and granularity change the numbers and when blending is the better choice.

    SQL & Datatableaudata-blendingjoinsorder-of-operations
  • SQL & DataEasyModel answer
    Why a Garden Mulch Report Loses Its Non-Promo Days

    Diagnose a multi-join SQL report that undercounts mulch sales, trace the lost rows step by step, and rewrite it to return all 30 days with correct totals.

    SQL & Datasqlleft-joinwhere-vs-ondate-spine
  • SQL & DataMediumModel answer
    Why Does This Hive INSERT...SELECT Fail or Load Bad Data?

    Diagnose a failing Hive INSERT...SELECT into a partitioned ACID ORC table and explain, in order, the fixes for syntax, alignment, casts, partitions, settings and format.

    SQL & Datahiveinsert-selectdynamic-partitionstype-casting
  • SQL & DataMediumModel answer
    Best Video Category by Mean Watch Time in pandas

    Compute which category has the highest mean watch time across valid video rows, with null and nonpositive filtering, name lookup, lexicographic tie-breaks, and rounding.

    SQL & Datapandasaggregationhash-mapdata-cleaning
  • SQL & DataMediumModel answer
    Staggered-Rollout Panel and Weekly Rollup in SQL

    Write warehouse SQL that turns daily participation logs into a treatment-aware employee-day panel and a site-week participation table for a staggered-rollout DiD analysis.

    SQL & Datasqldifference-in-differencespanel-dataleft-join
  • SQL & DataMediumModel answer
    How a Three-Column MySQL Index Serves Different Queries

    Analyze how one composite InnoDB index handles three query shapes, covering leftmost-prefix seeks, ordering, range limits, index condition pushdown, and the cost of row lookups.

    SQL & Datamysqlinnodbcomposite-indexcovering-index
  • SQL & DataMediumModel answer
    Quarterly Take-Home Pay and Latest-Period Drop Report

    Write a query that totals each employee's first-quarter take-home pay and flags those whose most recent paycheck fell below the one before it, with the percentage drop.

    SQL & Datasqlwindow-functionsaggregationcte
  • SQL & DataEasyModel answer
    Series vs DataFrame, WHERE vs HAVING, and Finding Repeated Emails

    Three short data-engineering questions: contrast pandas Series and DataFrame, explain when SQL applies WHERE versus HAVING, and write a query that reports emails occurring more than once.

    SQL & Datasqlpandasgroup-byhaving
  • SQL & DataMediumModel answer
    Daily New, Retained and Churned Devices by Platform

    Write one SQL query that classifies devices as new, retained or churned for 2025-09-01 from a raw event log, and reports net growth overall and per platform.

    SQL & Datasqlcteretentiondeduplication
  • SQL & DataMediumModel answer
    Trust & Safety Exposure Queries on Daily Post Views

    Write three SQL queries over daily post views and per-policy risk scores: a windowed view threshold, nudity exposure share, and a monthly flagged-type mix.

    SQL & Datasqlwindow-functionsjoinsaggregation
  • SQL & DataMediumModel answer
    Master SQL Window Functions: Ranking, Running Totals, and Gap-Fill

    Write analytical SQL queries using only window functions — no self-joins — to compute running totals, forward-fill sparse events, and rank users within groups.

    SQL & Datawindow-functionsrankingrunning-totalforward-fill
  • SQL & DataMediumModel answer
    Food Platform Analytics: Basket Pricing and Order Metrics

    Design functions to find the best-priced restaurant for a shopping cart, calculate revenue metrics over time windows, and identify top orders and items.

    SQL & Datadata-structuresaggregationwindow-queriesheap
  • SQL & DataHardModel answer
    Design a University Enrollment Schema, Warehouse, and SQL

    Model a university domain in 3NF, build a star schema with SCD Type 2 history, plan partitioning for 100M+ rows, and write two analytic queries.

    SQL & Datadata-modelingstar-schemaSCDpartitioning
  • SQL & DataMediumModel answer
    User-Week Panel Construction and DiD Analysis in SQL

    Build a clean user-week panel dataset for difference-in-differences analysis, handling treatment timing, household spillovers, and staggered adoption.

    SQL & Datadifference-in-differencespanel-datacausal-inferencesql-aggregation
  • SQL & DataMediumModel answer
    E-commerce Event Aggregation: Metrics and Ranking

    Aggregate event logs to compute shop exposure metrics, normalize by observation period, rank within categories using window functions, and segment user engagement by tenure.

    SQL & Dataaggregationwindow-functionsjoinscase-expressions
  • SQL & DataMediumModel answer
    Code Review: Geospatial Data Processing Pipeline

    Evaluate a Python module that computes distances and clusters geographic points from CSV/GeoJSON sources, identifying bugs, performance issues, and production risks.

    SQL & Datacode-reviewgeospatialpythondata-processing
  • SQL & DataMediumModel answer
    Daily Spend Leaders and Cost-Efficiency by Campaign Goal

    Rank the top daily advertisers with ties, then compute cost per KPI by goal using a launch-date filter and safe division.

    SQL & Datawindow-functionsaggregationjoinsdivision-by-zero
  • SQL & DataMediumModel answer
    Retail Spend Analytics: Aggregation and Regional Rankings

    Write two SQL queries against a payment dataset to find top vendors globally and per region using aggregation, joins, and window-based dense ranking.

    SQL & Datawindow-functionsaggregationCTEranking
  • SQL & DataMediumModel answer
    Daily Driver Earnings with Time-Based Bonuses

    Calculate a courier's total earnings per day from delivery records, applying distance rates, minimum guarantees, and optional surge multipliers for high-demand hours.

    SQL & Datadata-processingbusiness-logictime-windows
  • SQL & DataMediumModel answer
    Social Network Feed Analytics with SQL Aggregation

    Build SQL queries to analyze user engagement patterns across friend and non-friend content, handling temporal aggregation and interaction scoring.

    SQL & Datasqldata-aggregationwindow-functionsjoins
  • SQL & DataMediumModel answer
    Auditing a Credit-Card Ledger: Validation Rules and Failing-Row Queries

    Design a layered set of data quality checks over transactions and vendors tables, with SQL for the failing rows.

    SQL & Datadata-qualitysqlvalidationreferential-integrity
  • SQL & DataMediumModel answer
    Find the Meeting Slot That Conflicts With the Most Others

    Given a table of time-bounded sessions, write SQL to find which session overlaps the largest number of other sessions and report that count.

    SQL & Datasqlinterval-overlapself-joinwindow-functions
  • SQL & DataMediumModel answer
    Daily Ledger Reconciliation with FX Rates and Late Postings

    Build SQL reconciliation across two ledgers with as-of FX conversion, 48h late-arrival classification, an idempotent backfilling pipeline, and honest discrepancy reporting.

    SQL & Datasqldata-engineeringwindow-functionsetl
  • SQL & DataEasyModel answer
    Aggregate ZIP-Level Population Data with SQL Joins

    Write a SQL query to compute total city population by summing ZIP code records, handling joins and duplicate city names across regions.

    SQL & Datasqljoinsaggregationgroup-by
  • SQL & DataEasyModel answer
    Keeping LEFT JOIN Intact While Picking One Shipment per Order

    Explain why moving a shipment predicate from ON to WHERE turns a LEFT JOIN into an INNER JOIN, then write a query that keeps every qualifying order and attaches only its latest expedited shipment.

    SQL & Datasqljoinswindow-functionsdata-modeling