KatInterview

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

SQL & Data Interview Problems

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

5966
Problems
2209
Auto-graded
15
Topics
271
Added today

Showing 1–30 of 100 results

  • SQL & DataMediumAuto-graded
    Consolidate E-Commerce Orders into Fact Records

    Process and aggregate relational records across multiple entity tables into a single denormalized fact dataset.

    SQL & Datasqlarraysdata-manipulationhash-map
  • SQL & DataEasyAuto-graded
    Month-over-Month Revenue Change per Store

    Group order records by store and calendar month, then compute each month's percentage change versus the store's previous active month, handling zero totals and gaps.

    SQL & Dataaggregationgroup-bywindow-functionsdictionaries
  • SQL & DataEasyAuto-graded
    Content Flagging System Metrics and Abuse Analysis

    Process moderation report logs to calculate unique report ratios and aggregate key reporting metrics per reporter.

    SQL & Dataarraysdictionariesdata-processingmetrics
  • SQL & DataMediumAuto-graded
    Daily Active Users, New-User Cohorts and Next-Day Return Rate

    Build a fixed 7-day report of active users, first-activity cohorts, next-day return rate and revenue per active user from raw logs, with bot filtering and deduplication.

    SQL & Datacohort-analysisretentiondeduplicationhash-sets
  • SQL & DataMediumAuto-graded
    Top Earners per Department with Ties

    Given department and employee tables as lists, return every employee who earns the maximum salary in their department, keeping ties and handling duplicate names.

    SQL & Datagroup-byhash-maptiesjoins
  • SQL & DataMediumAuto-graded
    Retail Reports: Product Revenue Stats and Regional Customer Ranks

    Emulate SQL-style reporting in Python: grouped mean and population stddev, NULL-to-zero mapping, inner joins across three tables, and RANK/DENSE_RANK within partitions.

    SQL & Datasqlgroup-byjoinswindow-functions
  • SQL & DataEasyAuto-graded
    Name the Anomaly in an Interleaved Two-Transaction Schedule

    Identify which classic concurrency anomaly a fixed read/read/write/write schedule on one shared value produces, and return the matching option letter.

    SQL & Datatransactionsconcurrencyisolation-levelsserializability
  • SQL & DataEasyAuto-graded
    Sponsors Active in Both Opening Weeks

    Given a log of ad submission rows, find the sponsors with at least one submission in week 1 and at least one in week 2, returned sorted, which tests set intersection and deduplication.

    SQL & Datasetsdeduplicationintersectiondata-manipulation
  • SQL & DataEasyAuto-graded
    Users Logging In Successfully From Several Countries

    Group login records by user, keep only exact-match successful ones, and report users whose successful logins span at least two distinct countries, sorted.

    SQL & Datahash-mapsetsfilteringgroup-by
  • SQL & DataMediumAuto-graded
    Best-Scoring Enrollee for Each Academic Department

    Pick one top student per department from two record lists, using GPA with deterministic tie-breaks, skipping missing values, and keeping departments that have no eligible student.

    SQL & Datagroup-wise selectionleft jointie-breakingnull handling
  • SQL & DataMediumAuto-graded
    Monthly Line Output Report with Running Totals and Defect Percent

    Group daily production records by line and month, add a per-line running total, and compute each month's defect percentage from summed counts.

    SQL & Datagroup-byhashingrunning-totalaggregation
  • SQL & DataEasyAuto-graded
    Unify Two Yearly Sales Record Lists With a Mismatched Key

    Tests normalizing records from two sources with a misspelled field name, casting a numeric field to float, and concatenating the lists in order without mutating inputs.

    SQL & Datadata-cleaningdictionariesschema-alignmentconcatenation
  • SQL & DataMediumAuto-graded
    Find Riders Idle Through the Latest Week of Activity

    Given user and ride records, return users with no ride in the 7-day window ending at the latest ride date, including users who never rode, sorted by user_id.

    SQL & Dataanti-joindate-windowhash-setfiltering
  • SQL & DataMediumAuto-graded
    Weekly Totals with 3-Week Rolling Sum in Pacific Time

    Bucket timestamped payments into Pacific-time Monday weeks, fill empty weeks with zero, and report weekly and trailing three-week totals.

    SQL & Datatime zonesdate bucketingrolling windowaggregation
  • SQL & DataMediumAuto-graded
    Top Opening Film Across Subscriber Watch Logs

    Find each user's earliest-watched title, then pick the title that opens the most users' histories, using deterministic tie-breaking rules.

    SQL & Datahash-mapaggregationtie-breakinggroup-by
  • SQL & DataMediumAuto-graded
    Cheapest Top-Rated Purchase per Category

    Join 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.

    SQL & Dataaggregationleft-joinnull-handlinggroup-by
  • SQL & DataEasyAuto-graded
    Daily Spend Ranking for Frequent Payers

    Filter 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).

    SQL & Datawindow-functionsgroupingrankingsorting
  • SQL & DataMediumAuto-graded
    Day-30 Cohort Retention from Signup and Activity Logs

    Group users into signup-date cohorts and count who was active exactly 30 days later, using sets and date arithmetic with careful handling of duplicates.

    SQL & Datahash-setdate-arithmeticaggregationcohort-analysis
  • SQL & DataMediumAuto-graded
    Top Three Categories by Average October Sale Value

    Filter 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.

    SQL & Dataaggregationhash-mapgroup-bysorting
  • SQL & DataMediumAuto-graded
    Find Bottom Three Active Regions by Unique User Count

    Aggregate user log data to calculate distinct active users per country in 2023, then return the 3 least active countries.

    SQL & Dataarrayshash-tablesortingaggregation
  • SQL & DataEasyAuto-graded
    Loan Count Gap Between Newest Member and Their Sponsor

    Tests 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.

    SQL & Dataaggregationhash-mapnull-handlingjoins
  • SQL & DataMediumAuto-graded
    Rebuild a Seven-Day Account Exposure Report from Trade Feeds

    Deduplicate late-arriving trade versions, filter by status, window and KYC, then aggregate per account and day into exposure, utilization and breach figures.

    SQL & Datadata-manipulationdeduplicationaggregationjoins
  • SQL & DataEasyAuto-graded
    Find Nth Highest Distinct Salary

    Find the Nth highest unique value in a list of integers, returning None if N is out of valid bounds.

    SQL & Dataarrayssortingsql
  • SQL & DataMediumAuto-graded
    Analyze Live Streaming Telemetry and Viewing Events

    Process minute-level streaming activity and viewer events to calculate time-series metrics, category shares, month-over-month growth, and joined yearly summaries.

    SQL & Datadata-aggregationtime-seriesjoinsanalytics
  • SQL & DataMediumAuto-graded
    Daily SHOP vs WEBSITE Revenue Mix and Efficiency Report

    Aggregate 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.

    SQL & Dataaggregationhash-mapdate-windowdata-manipulation
  • SQL & DataMediumAuto-graded
    Flag Account Takeovers: New Login Followed by a Large Transfer

    Join 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.

    SQL & Datadata-manipulationtime-windowsjoinsfraud-detection
  • SQL & DataMediumAuto-graded
    Standardize Global Compensation and Rank Top Earners

    Deduplicate employee records across regions, convert local salaries to USD using historical exchange rates, and rank the top earners.

    SQL & Datadata-manipulationhash-mapsortingsql
  • SQL & DataMediumAuto-graded
    Park Ticket Revenue and Pass-Holder Visit Averages

    Aggregate ticket revenue and shares, then compute average distinct in-period visits per annual-pass period, including zero-visit passes, to project total entries.

    SQL & Dataaggregationjoinsdate-range-filteringhash-map
  • SQL & DataMediumAuto-graded
    Calculate Monthly Subscription Churn and Revenue Retention

    Process monthly user subscription snapshots to compute customer churn rate, gross revenue churn, and net revenue retention metrics.

    SQL & Datadata-manipulationaggregationssaas-metricssql
  • SQL & DataEasyAuto-graded
    Calculate Call Answer Metrics for Active Users

    Process call records and lifecycle logs to compute the success rate of answered calls for eligible users within a specific time frame.

    SQL & Datasqlarrayshash-table