KatInterview

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

SQL 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 31–60 of 100 results

  • SQL & DataMediumAuto-graded
    Segment Survey Ratings by User Tenure and Region

    Filter invalid responses, categorize users by signup tenure, and aggregate satisfaction metrics by region and cohort.

    SQL & Datadata manipulationaggregationgroupingfiltering
  • SQL & DataMediumAuto-graded
    Find Top-Funded Municipalities and Their Leading Projects

    Aggregate relational records over a specific date window to identify peak entities with tie preservation at multiple hierarchical levels.

    SQL & Dataarrayshash-tablesortingdate-parsing
  • SQL & DataMediumAuto-graded
    Longest Average Calls Leaderboard Since a Cutoff

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

    SQL & Datagroup-byaggregationdatetimesorting
  • SQL & DataMediumAuto-graded
    Premium Viewing Hours Rolled Up by Week and Month

    Filter viewing events to premium subscribers, bucket them into Monday-start weeks and calendar months per user, sum minutes into hours, and return a sorted long-format result.

    SQL & Dataaggregationgroup-bydateshash-map
  • SQL & DataMediumAuto-graded
    Prefix Totals by Value Across Duplicate-Heavy Records

    Compute, for each record, the total of all values in the dataset that do not exceed its own value, handling ties and large inputs efficiently via grouping and a running total.

    SQL & Dataaggregationprefix-sumsortinghash-map
  • SQL & DataEasyAuto-graded
    Sum Open Credit Balances per Customer, Sorted by ID

    Filter records by a status value, total a numeric field per customer ID, and return the results sorted by ID, mirroring a SQL filter, group and order query in Python.

    SQL & Datahash-mapaggregationgroup-bysorting
  • SQL & DataMediumAuto-graded
    Pick the Title Winner from Mixed-Orientation Game Records

    Given team and game record lists, find the 2023 championship winner when the winner may be on either side, with a deterministic highest-score tie-break.

    SQL & Datadata-manipulationjoinsfilteringhash-map
  • SQL & DataMediumAuto-graded
    Daily Tally of Users Who Posted on Their Signup Day

    Given user and post records with timestamps, count per signup date how many users published at least one post that same calendar day, counting each user once.

    SQL & Datahash-mapdatesdedupaggregation
  • SQL & DataMediumAuto-graded
    Live Stream Creator Stats: Weekly, Monthly Rankings and Daily Check

    Join two record lists on a composite key with missing-row defaults, then compute a filtered distinct count, a per-group top-5 ranking with tie-breaks, and an every-item condition check.

    SQL & Datajoinsgroup-byrankingtie-breaking
  • SQL & DataMediumAuto-graded
    Top Two Spending Categories per Shopper with Share of Spend

    Aggregate line-item spend by shopper and category, rank with ties, keep the top two ranks, add spend share, and handle shoppers with no purchases.

    SQL & Dataaggregationgroupingrankingjoins
  • SQL & DataEasyAuto-graded
    Creator Reach Score and Monthly New-Follower Trends

    Join and aggregate social-graph records to compute per-user reach scores and per-month follower statistics, including previous-month lookups, growth rates and running totals.

    SQL & Dataaggregationjoinswindow-functionshash-map
  • SQL & DataEasyAuto-graded
    Current Top Earner in Each Department

    Reduce salary history to each person's current pay per department, then choose the highest-paid person in each department, with exact tie and ordering rules.

    SQL & Datagroupinghash-mapdata-manipulationtop-n-per-group
  • SQL & DataMediumAuto-graded
    Daily Leading Buyers Among Active Subscribers

    Filter orders by inclusive membership windows, total quantities per day and customer, and return every customer tied for each day's maximum, in sorted order.

    SQL & Dataaggregationgroup-bytiesdate-range-filter
  • SQL & DataMediumAuto-graded
    Coupon Campaign Conversion and 48-Hour Spend Report

    Build a per-user cohort from coupon events, then join transactions by time window to compute cohort size, converters, and spend within 48 hours.

    SQL & Datajoinshash-mapdatetimeaggregation
  • SQL & DataMediumAuto-graded
    Tally Faulty and Clean Submissions per Company

    Aggregate two conditional counts per group from two related row lists, keeping groups with no matching rows and handling both boolean and string status values.

    SQL & Dataconditional-aggregationleft-joinhash-mapgroup-by
  • SQL & DataEasyAuto-graded
    Sessionize Clickstream Events with a 30-Minute Inactivity Gap

    Deduplicate retried events, split each user's activity into sessions on gaps over 30 minutes, and summarize each session with its start, end and distinct page count.

    SQL & Datasessionizationwindow-functionsdeduplicationgaps-and-islands
  • SQL & DataMediumAuto-graded
    Variant-Level Tutorial Finish Rate Within a One-Week Window

    Join users to step events, cap each user's progress at a 7-day window, infer each variant's final step, and compute per-variant completion shares.

    SQL & Datahash-mapaggregationdatetimecohort-analysis
  • SQL & DataHardAuto-graded
    Compute Per-Warehouse Reorder Alerts from Inventory Logs

    Tests group-by aggregation over a list-of-dict records, computing per-warehouse stock summaries and flagging items that need reordering.

    SQL & Datadata processinggroup-by aggregationdictionaries
  • SQL & DataMediumAuto-graded
    Per-Account Usage Means Above a Threshold

    Group readings by account id, keep accounts whose unrounded mean CPU, memory, or disk usage tops 50, then emit half-up rounded, email-sorted records.

    SQL & Dataaggregationgroupinghashingsorting
  • SQL & DataEasyAuto-graded
    Reconcile User Settings from Snapshot and Activity Log

    Tests table joins, state reconciliation, and handling baseline data overridden by timestamped events

    SQL & Datadata-manipulationjoinsstate-reconciliation
  • SQL & DataMediumAuto-graded
    Player Activity Running Totals with Date Gaps

    Tests aggregation, running sums, and date-range densification without recursion—core skills for analytics pipelines.

    SQL & Datawindow-functionsaggregationdate-handling
  • SQL & DataMediumAuto-graded
    Per-Group Top-3 Distinct Values with Tie Handling

    Tests whether you can isolate the three highest distinct numeric values within each group and return all records that match those values, preserving correct sort order.

    SQL & Datagroupingdense-ranksorting
  • SQL & DataMediumAuto-graded
    MySQL Expression Results

    Tests understanding of MySQL type coercion, boolean evaluation, and string comparison functions.

    SQL & Datatype-coercionsqlboolean-logic
  • SQL & DataMediumAuto-graded
    Reduce Subscription Events to Latest User Status

    Collapse an append-only subscription event log into one status row per user, picking the newest event per user with a deterministic tie-break.

    SQL & Dataevent-logdeduplicationgroupingdatetime-parsing
  • SQL & DataMediumAuto-graded
    Aggregate Sales Totals by Month Across a Full Year

    Tests ability to join two relational datasets, filter by year, and produce a complete 12-row monthly summary including zero-revenue months.

    SQL & Dataaggregationjoindate-manipulation
  • SQL & DataMediumAuto-graded
    Multi-Table Sales Analytics with Referral Tracking

    Tests relational data manipulation through joins, aggregations, filtering, and ranking across interconnected tables.

    SQL & Dataaggregationjoinsfilteringsorting
  • SQL & DataMediumAuto-graded
    Count Distinct Users by Department and Time Window

    Tests set-based deduplication and join logic to find unique users who interacted with products in a specific department during a time range.

    SQL & Datadata-manipulationset-operationsfiltering
  • SQL & DataMediumAuto-graded
    Join User Profiles and Purchase Records, Fill Gaps, Compute Line Spend

    Tests left-join logic, mode imputation for missing categorical fields, and null-safe row-level spend calculation using plain Python dicts.

    SQL & Datadata-manipulationjoinsnull-handling
  • SQL & DataMediumAuto-graded
    Daily Campaign Performance Summary Over a Rolling Window

    Tests conditional aggregation across multiple related tables, time-window filtering, fan-out avoidance, and safe division when computing per-day engagement rates.

    SQL & Dataaggregationjoindata-manipulation
  • SQL & DataMediumAuto-graded
    Purchase Line-Item Cost Calculator with Validation

    Tests data validation, numeric robustness, error handling, aggregation, and sorting in a billing calculation task

    SQL & Datadata-validationaggregationsorting