Branch
SQL & Data Modeling interview questions
Window functions, joins, funnels and event models under interview time pressure.
20 practice questions · 10 subtopics · hints and unlimited attempts
What this branch covers
Window Functions
Ranking, running totals, gaps and islands.
Window Functions questionsFunnels & Sessions
Event sequencing and sessionization.
Funnels & Sessions questionsSchema Design
Fact/dimension choices and grain.
Schema Design questionsGaps & Islands
Finding streaks, gaps and continuous runs in event data.
Gaps & Islands questionsSessionization
Turning raw events into sessions with time-gap rules.
Sessionization questionsDeduplication
Removing duplicate rows and keeping the record that matters.
Deduplication questionsCohort Retention
Cohorting users and measuring return behavior over time.
Cohort Retention questionsAggregation
Grouping, filtering and conditional aggregation for reporting.
Aggregation questionsSelf Joins
Comparing rows within a table to rank, pair or sequence them.
Self Joins questionsPivoting
Reshaping long data into report-ready columns.
Pivoting questions
All SQL & Data Modeling questions
Second highest order per customer
Rank orders per customer and return each customer's second largest order.
Window Functions · sql · medium · 12 min
Signup to purchase funnel
ProBuild a three-step funnel from an events table with conversion rates.
Funnels & Sessions · sql · hard · 18 min
Choosing the fact table grain
Pick the right grain for an order-line fact table.
Schema Design · multiple choice · easy · 6 min
Running total of daily revenue
From the orders table, return each order_date with that day's revenue and a cumulative running total of revenue through that date, ordered by date.
Window Functions · sql · medium · 10 min
Trailing 7-day active users
ProFrom an events table, for each calendar date return the number of DISTINCT users active in the trailing 7 days (that date and the 6 days before it).
Window Functions · sql · hard · 15 min
Month-over-month revenue growth
Return each month, its revenue, and the month-over-month growth as a percentage rounded to one decimal.
Window Functions · sql · medium · 10 min
Top 3 products per category by revenue
Return the top 3 products by total revenue within each category.
Window Functions · sql · medium · 12 min
Longest consecutive login streak
ProEach row is one calendar day a user logged in (no duplicates).
Gaps & Islands · sql · hard · 18 min
Sessionize events with a 30-minute gap
ProAssign a session id to each event per user, starting a new session whenever the gap since the user's previous event exceeds 30 minutes.
Sessionization · sql · hard · 18 min
Keep only the latest record per listing
The snapshots table has multiple rows per listing.
Deduplication · sql · medium · 10 min
Day-7 retention by signup cohort
ProFor each signup date cohort, return the cohort size and the Day-7 retention rate: the share of users who were active exactly 7 days after signup.
Cohort Retention · sql · hard · 18 min
Median order value per segment
Return the median order amount for each customer segment.
Aggregation · sql · medium · 8 min
Users who viewed then purchased the same item
Count the distinct users who VIEWED a product and later PURCHASED that same product (purchase time strictly after the view).
Self Joins · sql · medium · 12 min
Pivot monthly revenue into columns
Return one row per category with three columns of revenue: Jan, Feb, and Mar 2026.
Pivoting · sql · medium · 10 min
Which change needs a Type 2 dimension
You maintain a customer dimension.
Schema Design · multiple choice · medium · 6 min
Longest monthly activity streak
For each user, return the length of their longest streak of consecutive calendar months with at least one activity.
Window Functions · sql · medium · 18 min
Sessionize events with a 30-minute gap
ProCreate sessions separately for each user.
Funnels & Sessions · sql · hard · 25 min
Week-one retention by signup cohort
Group users by Monday-starting signup week.
Funnels & Sessions · sql · medium · 20 min
Join each invoice to the plan in effect
ProEach plan_history row starts a new plan period for an account and remains effective until the next change.
Schema Design · sql · hard · 22 min
Rolling seven-day cancellation rate
ProFor every calendar date from the first through last order date, compute the trailing seven-calendar-day cancellation rate: canceled orders divided by all orders in that date and the prior six dates.
Window Functions · sql · hard · 22 min
Other branches
Start with SQL & Data Modeling
A free account keeps your attempt history and progress. Premium sets are included in Pro and Founder plans.