SQL Interview Questions
All 91 questions — full access
1 Q01 Top 2 highest-grossing products within each category in 2022 ▼
See the study guide for the detailed answer →
2 Q02 Top 3 salaries in each department ▼
See the study guide for the detailed answer →
3 Q03 Email activity rank per user (sent + received + spam, dense ranked) ▼
See the study guide for the detailed answer →
4 Q04 Top 2 users per company with most calls (maintain ties) ▼
See the study guide for the detailed answer →
5 Q05 Most-used vehicle type in past year (excluding cancelled rides) ▼
See the study guide for the detailed answer →
6 Q06 Olympic swimmers who won ONLY gold medals — count golds each ▼
See the study guide for the detailed answer →
7 Q07 Nominee who won the most Oscars ▼
See the study guide for the detailed answer →
8 Q08 Top 10 users by total distance across all rides ▼
See the study guide for the detailed answer →
9 Q09 Top 5 product pairs most frequently purchased together ▼
See the study guide for the detailed answer →
10 Q10 Top 3 departments by average salary ▼
See the study guide for the detailed answer →
11 Q11 Cumulative merchant transaction balance, reset at start of each month ▼
See the study guide for the detailed answer →
12 Q12 Cumulative users added daily, reset at start of each month ▼
See the study guide for the detailed answer →
13 Q13 Running total revenue by product category in 2022 ▼
See the study guide for the detailed answer →
14 Q14 Cumulative salary of employee for 3 months excluding most recent (LeetCode Hard) ▼
See the study guide for the detailed answer →
15 Q15 Total server fleet uptime across overlapping maintenance windows ▼
See the study guide for the detailed answer →
16 Q16 Month-over-month change in revenue for 2019 ▼
See the study guide for the detailed answer →
17 Q17 Duplicate payments: same merchant+card+amount within 10 minutes ▼
See the study guide for the detailed answer →
18 Q18 Average delay between sign-up and 2nd ride (in-the-moment users) ▼
See the study guide for the detailed answer →
19 Q19 Twitter rolling 3-day average number of tweets per user ▼
See the study guide for the detailed answer →
20 Q20 % buyers who purchased AirPods directly after iPhone (next purchase) ▼
See the study guide for the detailed answer →
21 Q21 Countries that moved higher in comment ranking Dec→Jan ▼
See the study guide for the detailed answer →
22 Q22 3 largest month-over-month call declines by company ▼
See the study guide for the detailed answer →
23 Q23 Users whose 2nd purchase was within 48 hours of 1st ▼
See the study guide for the detailed answer →
24 Q24 Rows where purchase amount grew vs previous transaction ▼
See the study guide for the detailed answer →
25 Q25 Top 3 users with longest continuous login streak ▼
See the study guide for the detailed answer →
26 Q26 Employees who worked consecutive days for at least 5 days straight ▼
See the study guide for the detailed answer →
27 Q27 Periods of inactivity for each supplier — longest gap between orders ▼
See the study guide for the detailed answer →
28 Q28 Users who placed orders every week for 4+ consecutive weeks ▼
See the study guide for the detailed answer →
29 Q29 Stocks with consecutive days of price increases (3+ in a row) ▼
See the study guide for the detailed answer →
30 Q30 Date ranges when a server was continuously online ▼
See the study guide for the detailed answer →
31 Q31 Users with no activity for 30+ days at any point in history ▼
See the study guide for the detailed answer →
32 Q32 Assign session_id to each event (new session = 30 min inactivity) ▼
See the study guide for the detailed answer →
33 Q33 Average session duration per user (session = 30 min gap) ▼
See the study guide for the detailed answer →
34 Q34 Users with highest number of sessions in a given month ▼
See the study guide for the detailed answer →
35 Q35 Sessions that resulted in a purchase within the same session ▼
See the study guide for the detailed answer →
36 Q36 Users whose first session was as viewer but later became streamer ▼
See the study guide for the detailed answer →
37 Q37 Count duplicate customer_id entries from ETL bug ▼
See the study guide for the detailed answer →
38 Q38 From CDC table, keep most recent record per customer_id ▼
See the study guide for the detailed answer →
39 Q39 Duplicate transaction_ids — keep record with highest amount ▼
See the study guide for the detailed answer →
40 Q40 Users with more than one account (same email, different user_ids) ▼
See the study guide for the detailed answer →
41 Q41 Deduplicate user_profiles keeping lowest user_id per email ▼
See the study guide for the detailed answer →
42 Q42 Employees who earn more than their direct manager ▼
See the study guide for the detailed answer →
43 Q43 Friend recommendations: users who attend 2+ same events, not already friends ▼
See the study guide for the detailed answer →
44 Q44 Pairs of students in same class who scored within 5 points of each other ▼
See the study guide for the detailed answer →
45 Q45 Cheapest two-stop routes between any origin-destination pair ▼
See the study guide for the detailed answer →
46 Q46 Players who beat same opponent at least twice ▼
See the study guide for the detailed answer →
47 Q47 Managers with at least 5 direct reports ▼
See the study guide for the detailed answer →
48 Q48 All possible size-color combinations for new product line ▼
See the study guide for the detailed answer →
49 Q49 Full date × product grid, LEFT JOIN sales to find zero-sales days ▼
See the study guide for the detailed answer →
50 Q50 Full round-robin tournament schedule from teams table ▼
See the study guide for the detailed answer →
51 Q51 All 3-topping pizza combinations with total cost ▼
See the study guide for the detailed answer →
52 Q52 Full region × category grid for monthly report (zero-fill) ▼
See the study guide for the detailed answer →
53 Q53 Top 5 pairs of products most frequently bought together ▼
See the study guide for the detailed answer →
54 Q54 Product most commonly bought alongside Product X ▼
See the study guide for the detailed answer →
55 Q55 Product pairs where co-purchase count > 100 with lift score ▼
See the study guide for the detailed answer →
56 Q56 Menu item pairs ordered together more than 30% of the time ▼
See the study guide for the detailed answer →
57 Q57 Downloads for paying vs non-paying users by date (filter where non-paying > paying) ▼
See the study guide for the detailed answer →
58 Q58 Click-through rate: 100 × clicks / impressions per app ▼
See the study guide for the detailed answer →
59 Q59 Pivot monthly revenue by product category (categories become columns) ▼
See the study guide for the detailed answer →
60 Q60 Users active on exactly 3 out of past 7 days ▼
See the study guide for the detailed answer →
61 Q61 Orders placed per quarter (Q1,Q2,Q3,Q4) as separate columns per user ▼
See the study guide for the detailed answer →
62 Q62 Twitch users who are both streamers and viewers — count sessions per type ▼
See the study guide for the detailed answer →
63 Q63 Monthly active users in July 2022 (active in BOTH June and July) ▼
See the study guide for the detailed answer →
64 Q64 Retention rate of monthly sign-up cohort for months 1, 2, and 3 ▼
See the study guide for the detailed answer →
65 Q65 Day-7 retention rate for January 2024 sign-ups ▼
See the study guide for the detailed answer →
66 Q66 Weekly sign-up cohort: % who made 2nd purchase within 30 days ▼
See the study guide for the detailed answer →
67 Q67 D1, D7, D30 retention side-by-side per monthly sign-up cohort ▼
See the study guide for the detailed answer →
68 Q68 How unsubscribes affect login rates over 4 weeks after event ▼
See the study guide for the detailed answer →
69 Q69 Days between first and last post of year per user (at least 2 posts) ▼
See the study guide for the detailed answer →
70 Q70 Average hours between order placement and delivery (2023) ▼
See the study guide for the detailed answer →
71 Q71 Employees at company 5+ years but never promoted ▼
See the study guide for the detailed answer →
72 Q72 % incomplete orders and revenue lost in past 90 days ▼
See the study guide for the detailed answer →
73 Q73 Subscription renewals more than 7 days late ▼
See the study guide for the detailed answer →
74 Q74 All employees reporting directly/indirectly to manager_id = 5 ▼
See the study guide for the detailed answer →
75 Q75 Total subordinate count (direct + indirect) for each manager ▼
See the study guide for the detailed answer →
76 Q76 Product categories and all subcategories recursively ▼
See the study guide for the detailed answer →
77 Q77 Full dependency chain for a given task (task depends on task) ▼
See the study guide for the detailed answer →
78 Q78 Generate date spine 2024-01-01 to 2024-12-31 using recursive CTE ▼
See the study guide for the detailed answer →
79 Q79 All reachable destinations from an origin city (multi-hop flights) ▼
See the study guide for the detailed answer →
80 Q80 Median number of searches per user from frequency distribution table ▼
See the study guide for the detailed answer →
81 Q81 Median salary of employees in each department ▼
See the study guide for the detailed answer →
82 Q82 90th percentile response time per API endpoint in past week ▼
See the study guide for the detailed answer →
83 Q83 Divide users into 4 quartiles by total purchase amount 2023 ▼
See the study guide for the detailed answer →
84 Q84 Median days between 1st and 2nd purchase for customers with 2+ purchases ▼
See the study guide for the detailed answer →
85 Q85 Count of users at each funnel stage + step-to-step conversion rate ▼
See the study guide for the detailed answer →
86 Q86 Signup-to-activation rate (confirmed phone / total signed up) ▼
See the study guide for the detailed answer →
87 Q87 Drop-off rate at each step of onboarding funnel ▼
See the study guide for the detailed answer →
88 Q88 Click-through-to-conversion rate per ad campaign ▼
See the study guide for the detailed answer →
89 Q89 Funnel step with highest drop-off for new users in first 7 days ▼
See the study guide for the detailed answer →
90 Q90 Free trial → paid conversion rate changes across monthly cohorts ▼
See the study guide for the detailed answer →
91 Q91 [Your question text] ▼
See the study guide for the detailed answer →