30-Minute SQL Mock
Interview Mock Timer
Use this timer to simulate interview pressure. Prioritize correctness, then explain tradeoffs.
20:00
Use this lesson to simulate a realistic SQL interview with strict timing and evaluator-style scoring.
Round Plan (30 Minutes) #
- 0-5 min: clarify assumptions and output grain
- 5-18 min: write first-correct query
- 18-25 min: add validation and edge-case handling
- 25-30 min: explain tradeoffs and final answer
Mock Prompt #
For each month, return completed-order revenue, purchasing customers, and month-over-month revenue growth. Revenue is SUM(order_total) over completed orders (order grain, so do not sum line items); growth is the month-over-month percent change.
Required output columns (use these exact aliases):
- month_start
- revenue
- purchasing_customers
- mom_revenue_growth
Loading SQL editor...
Validation Queries #
sql
-- Revenue baseline
SELECT
DATE_TRUNC('month', order_date) AS month_start,
ROUND(SUM(order_total), 2) AS revenue
FROM ecom_orders
WHERE order_status = 'completed'
GROUP BY DATE_TRUNC('month', order_date)
ORDER BY month_start;
-- Grain check (one row per month)
WITH monthly AS (
SELECT DATE_TRUNC('month', order_date) AS month_start
FROM ecom_orders
WHERE order_status = 'completed'
GROUP BY DATE_TRUNC('month', order_date)
)
SELECT month_start, COUNT(*) AS row_count
FROM monthly
GROUP BY month_start
HAVING COUNT(*) > 1;Evaluator Scorecard #
- Correctness (40%): SQL returns correct values at correct grain
- Validation (25%): evidence query confirms logic
- Communication (20%): assumptions/tradeoffs are explicit
- Time management (15%): solution completed within round
Common Fails in Timed Rounds #
- coding before clarifying definitions
- no validation query
- incorrect denominator logic for growth/ratios
- unfinished answer due over-optimization
Tip
Under time pressure, first-correct plus validation beats clever but unverified SQL.