Ties
ROW_NUMBER vs RANKrow_number() over (
partition by category
order by revenue desc)Two products tie for third place. ROW_NUMBER keeps one at random, so your top three is missing a row the moment the data has a tie.
Caught by hidden dataSQL interview practice for analysts
Real interview screens check your query on data you never see. Practise the same way: real PostgreSQL in your browser, and every answer graded on hidden datasets full of ties, NULLs, empty groups and duplicates.
select p.category,
coalesce(sum(oi.quantity * oi.unit_price)
filter (where o.status = 'completed'), 0) as revenue
from products p
left join order_items oi on oi.product_id = p.product_id
left join orders o on o.order_id = oi.order_id
group by p.category
order by revenue desc, p.category| category | revenue |
|---|---|
| Garden | 0 |
| Pets | 0 |
Where people fail
Most practice sites check your answer against the one table you can see. Real screens run it again on data built to break it. These three mistakes pass most samples and fail most screens.
row_number() over (
partition by category
order by revenue desc)Two products tie for third place. ROW_NUMBER keeps one at random, so your top three is missing a row the moment the data has a tie.
Caught by hidden datawhere campaign_id not in (
select campaign_id
from purchases)One NULL in the subquery and NOT IN returns nothing at all. The sample has no NULL there. The hidden data does.
Caught by hidden datafrom order_items oi
join products p
on p.product_id = oi.product_idA category with no sales should show 0. An inner join makes it vanish, and nothing on the sample tells you.
Caught by hidden dataHow a check works
Real tables, real types, instant results. Browse the schema, autocomplete column names, run with Ctrl + Enter.
Your query runs again on every hidden dataset in your browser. Rows are compared as a set, numbers with a fair rounding rule, order only when the question asks for it.
Missing rows in red, extra rows in amber, what the hidden data was testing, then hints, a worked solution and the wrong answers people usually write.
19 patterns
GROUP BY, HAVING and the grain of a result.
26Inner and outer joins, and rows that multiply.
24ROW_NUMBER, RANK, DENSE_RANK and top N per group.
18Window frames, moving averages and the row before.
14Breaking a question into steps you can check.
15Shares, rates and integer division traps.
15CASE inside aggregates, FILTER and pivots.
15Truncating, bucketing and date arithmetic.
11COALESCE, COUNT(column) and NULLs in filters.
10Month over month and year over year growth.
9Comparing rows of one table with each other.
9NOT EXISTS, LEFT JOIN ... IS NULL and the NOT IN trap.
10Finding duplicates and keeping one row per key.
10Grouping users by start month and tracking them.
8Step-by-step conversion, in order.
6Streaks, sessions and missing ranges.
5PERCENTILE_CONT, medians and distributions.
4String cleanup, UNION, INTERSECT and EXCEPT.
20Grain checks, type 2 history, date spines and as-of joins.
By role
Joins, aggregates, windows and the NULL traps every analyst screen leans on.
Open the set →150questionsRevenue, margins, period over period and the reporting questions BI teams ask.
Open the set →87questionsFunnels, cohorts, retention, activation and A/B test readouts.
Open the set →81questionsGrain checks, deduplication, type 2 history, date spines and as-of joins.
Open the set →Mock interviews
Timed mocks pull fresh questions for your role, hide hints and solutions until you finish, then score every answer on hidden data with your time per question.
See the mock interviewsPricing
$0
No account needed. Practise right away.
$19a month
Renews monthly. Cancel any time in two clicks.
$49$29once for 3 months
Three months of full access. Pay once, nothing renews.
Ends at 100 passes sold or on March 1, 2027, whichever comes first. Then the pass is $49.
Yes. Your queries run on PostgreSQL 19 compiled to WebAssembly, inside your browser tab. Nothing to install, no server round trip, and no way to break the data: every query runs read-only and is rolled back.
Each question has a sample dataset you can see and query, plus two or more hidden datasets built to catch specific mistakes: ties, NULLs, empty groups, duplicate rows and dates on the boundary. Your answer has to be right on all of them, the way automated interview screens grade take-homes.
No. Every question, dataset and solution here is written from scratch around the patterns interview screens test. Questions are tagged by pattern, role and difficulty, never by company.
The patterns are the same in every dialect. The dialect cheat sheet lists the few differences that come up in interviews, such as date functions, QUALIFY and integer division.
No. 65 questions, every lesson and one mock interview are free without signing up, and your progress is kept in your browser. Sign in with your email to keep progress across devices.
Every question with hints, worked solutions and the common wrong answers explained, all the timed mock interviews, and progress synced across devices. Monthly renews until you cancel. The interview pass is one payment for three months and never renews.