Practice · carbon.talent

SQL Practice Questions for Data Jobs

Last updated 18 Oct 2026

SQL is tested in almost every data interview. The questions below are original practice problems in a public, generic schema, with notes on how to approach each. These are original practice questions written for this page. They are not taken from, and do not preview, any assessment an employer or carbon.talent uses. Candidates on carbon.talent do not take or see any employer assessment through these pages.

Create your free profile Browse data jobs

The practice schema

Assume three tables: customers (customer_id, signup_date, country), orders (order_id, customer_id, order_date, status, amount) and events (event_id, customer_id, event_type, event_time, ingested_at).

Joins and aggregation

  1. Return the number of customers who signed up each month and how many placed at least one completed order within 30 days of signup. Approach: left join customers to completed orders within the window, group by signup month, count distinct customers with a matching order.
  2. List countries where the share of cancelled orders last quarter is higher than the overall share. Approach: compute the overall share in a subquery or CTE, then compare per-country shares.

Window functions

  1. For each customer, return each order with the previous order's date and the days between them. Approach: LAG over orders partitioned by customer and ordered by date.
  2. Return each customer's running total of completed order amounts. Approach: SUM with a window ordered by date, partitioned by customer.
  3. Find the top three customers by completed revenue in each country. Approach: aggregate, then ROW_NUMBER or DENSE_RANK partitioned by country, and explain how you treat ties.

Data quality

  1. Events may be ingested twice. Keep one row per event_id, choosing the earliest ingested_at. Approach: ROW_NUMBER partitioned by event_id ordered by ingested_at, keep row one.
  2. Find days in the last 90 with no events at all. Approach: generate a date series and left join event counts, filtering for zero.
  3. Orders refer to customers that do not exist. How would you detect them, and what would you do next? Approach: anti-join, then discuss whether to quarantine, alert or fix upstream.

How to practise

Write the query, then test it on a small sample you build yourself with edge cases: ties, nulls, duplicates and time zones. In interviews, say your assumptions out loud and explain how you would check the result.

Common questions

What SQL topics matter most for data interviews?
Joins, aggregation, window functions, date handling and data quality checks such as deduplication and anti-joins.
Are these the SQL tests carbon.talent uses?
No. Candidates do not take or see employer assessments through these pages. These are original practice questions.
Which SQL dialect should I practise?
Any mainstream dialect. Note differences in date functions and mention them in interviews.
How do I check my answers?
Build a small sample with edge cases such as ties, nulls and duplicates and confirm the output by hand.