🗃️
Question Bank

SQL Interview Questions

All 91 questions — full access

✓ Full Access 91 questions shown
← Study Guide
1 Top 2 highest-grossing products within each category in 2022

See the study guide for the detailed answer →

2 Top 3 salaries in each department

See the study guide for the detailed answer →

3 Email activity rank per user (sent + received + spam, dense ranked)

See the study guide for the detailed answer →

4 Top 2 users per company with most calls (maintain ties)

See the study guide for the detailed answer →

5 Most-used vehicle type in past year (excluding cancelled rides)

See the study guide for the detailed answer →

6 Olympic swimmers who won ONLY gold medals — count golds each

See the study guide for the detailed answer →

7 Nominee who won the most Oscars

See the study guide for the detailed answer →

8 Top 10 users by total distance across all rides

See the study guide for the detailed answer →

9 Top 5 product pairs most frequently purchased together

See the study guide for the detailed answer →

10 Top 3 departments by average salary

See the study guide for the detailed answer →

11 Cumulative merchant transaction balance, reset at start of each month

See the study guide for the detailed answer →

12 Cumulative users added daily, reset at start of each month

See the study guide for the detailed answer →

13 Running total revenue by product category in 2022

See the study guide for the detailed answer →

14 Cumulative salary of employee for 3 months excluding most recent (LeetCode Hard)

See the study guide for the detailed answer →

15 Total server fleet uptime across overlapping maintenance windows

See the study guide for the detailed answer →

16 Month-over-month change in revenue for 2019

See the study guide for the detailed answer →

17 Duplicate payments: same merchant+card+amount within 10 minutes

See the study guide for the detailed answer →

18 Average delay between sign-up and 2nd ride (in-the-moment users)

See the study guide for the detailed answer →

19 Twitter rolling 3-day average number of tweets per user

See the study guide for the detailed answer →

20 % buyers who purchased AirPods directly after iPhone (next purchase)

See the study guide for the detailed answer →

21 Countries that moved higher in comment ranking Dec→Jan

See the study guide for the detailed answer →

22 3 largest month-over-month call declines by company

See the study guide for the detailed answer →

23 Users whose 2nd purchase was within 48 hours of 1st

See the study guide for the detailed answer →

24 Rows where purchase amount grew vs previous transaction

See the study guide for the detailed answer →

25 Top 3 users with longest continuous login streak

See the study guide for the detailed answer →

26 Employees who worked consecutive days for at least 5 days straight

See the study guide for the detailed answer →

27 Periods of inactivity for each supplier — longest gap between orders

See the study guide for the detailed answer →

28 Users who placed orders every week for 4+ consecutive weeks

See the study guide for the detailed answer →

29 Stocks with consecutive days of price increases (3+ in a row)

See the study guide for the detailed answer →

30 Date ranges when a server was continuously online

See the study guide for the detailed answer →

31 Users with no activity for 30+ days at any point in history

See the study guide for the detailed answer →

32 Assign session_id to each event (new session = 30 min inactivity)

See the study guide for the detailed answer →

33 Average session duration per user (session = 30 min gap)

See the study guide for the detailed answer →

34 Users with highest number of sessions in a given month

See the study guide for the detailed answer →

35 Sessions that resulted in a purchase within the same session

See the study guide for the detailed answer →

36 Users whose first session was as viewer but later became streamer

See the study guide for the detailed answer →

37 Count duplicate customer_id entries from ETL bug

See the study guide for the detailed answer →

38 From CDC table, keep most recent record per customer_id

See the study guide for the detailed answer →

39 Duplicate transaction_ids — keep record with highest amount

See the study guide for the detailed answer →

40 Users with more than one account (same email, different user_ids)

See the study guide for the detailed answer →

41 Deduplicate user_profiles keeping lowest user_id per email

See the study guide for the detailed answer →

42 Employees who earn more than their direct manager

See the study guide for the detailed answer →

43 Friend recommendations: users who attend 2+ same events, not already friends

See the study guide for the detailed answer →

44 Pairs of students in same class who scored within 5 points of each other

See the study guide for the detailed answer →

45 Cheapest two-stop routes between any origin-destination pair

See the study guide for the detailed answer →

46 Players who beat same opponent at least twice

See the study guide for the detailed answer →

47 Managers with at least 5 direct reports

See the study guide for the detailed answer →

48 All possible size-color combinations for new product line

See the study guide for the detailed answer →

49 Full date × product grid, LEFT JOIN sales to find zero-sales days

See the study guide for the detailed answer →

50 Full round-robin tournament schedule from teams table

See the study guide for the detailed answer →

51 All 3-topping pizza combinations with total cost

See the study guide for the detailed answer →

52 Full region × category grid for monthly report (zero-fill)

See the study guide for the detailed answer →

53 Top 5 pairs of products most frequently bought together

See the study guide for the detailed answer →

54 Product most commonly bought alongside Product X

See the study guide for the detailed answer →

55 Product pairs where co-purchase count > 100 with lift score

See the study guide for the detailed answer →

56 Menu item pairs ordered together more than 30% of the time

See the study guide for the detailed answer →

57 Downloads for paying vs non-paying users by date (filter where non-paying > paying)

See the study guide for the detailed answer →

58 Click-through rate: 100 × clicks / impressions per app

See the study guide for the detailed answer →

59 Pivot monthly revenue by product category (categories become columns)

See the study guide for the detailed answer →

60 Users active on exactly 3 out of past 7 days

See the study guide for the detailed answer →

61 Orders placed per quarter (Q1,Q2,Q3,Q4) as separate columns per user

See the study guide for the detailed answer →

62 Twitch users who are both streamers and viewers — count sessions per type

See the study guide for the detailed answer →

63 Monthly active users in July 2022 (active in BOTH June and July)

See the study guide for the detailed answer →

64 Retention rate of monthly sign-up cohort for months 1, 2, and 3

See the study guide for the detailed answer →

65 Day-7 retention rate for January 2024 sign-ups

See the study guide for the detailed answer →

66 Weekly sign-up cohort: % who made 2nd purchase within 30 days

See the study guide for the detailed answer →

67 D1, D7, D30 retention side-by-side per monthly sign-up cohort

See the study guide for the detailed answer →

68 How unsubscribes affect login rates over 4 weeks after event

See the study guide for the detailed answer →

69 Days between first and last post of year per user (at least 2 posts)

See the study guide for the detailed answer →

70 Average hours between order placement and delivery (2023)

See the study guide for the detailed answer →

71 Employees at company 5+ years but never promoted

See the study guide for the detailed answer →

72 % incomplete orders and revenue lost in past 90 days

See the study guide for the detailed answer →

73 Subscription renewals more than 7 days late

See the study guide for the detailed answer →

74 All employees reporting directly/indirectly to manager_id = 5

See the study guide for the detailed answer →

75 Total subordinate count (direct + indirect) for each manager

See the study guide for the detailed answer →

76 Product categories and all subcategories recursively

See the study guide for the detailed answer →

77 Full dependency chain for a given task (task depends on task)

See the study guide for the detailed answer →

78 Generate date spine 2024-01-01 to 2024-12-31 using recursive CTE

See the study guide for the detailed answer →

79 All reachable destinations from an origin city (multi-hop flights)

See the study guide for the detailed answer →

80 Median number of searches per user from frequency distribution table

See the study guide for the detailed answer →

81 Median salary of employees in each department

See the study guide for the detailed answer →

82 90th percentile response time per API endpoint in past week

See the study guide for the detailed answer →

83 Divide users into 4 quartiles by total purchase amount 2023

See the study guide for the detailed answer →

84 Median days between 1st and 2nd purchase for customers with 2+ purchases

See the study guide for the detailed answer →

85 Count of users at each funnel stage + step-to-step conversion rate

See the study guide for the detailed answer →

86 Signup-to-activation rate (confirmed phone / total signed up)

See the study guide for the detailed answer →

87 Drop-off rate at each step of onboarding funnel

See the study guide for the detailed answer →

88 Click-through-to-conversion rate per ad campaign

See the study guide for the detailed answer →

89 Funnel step with highest drop-off for new users in first 7 days

See the study guide for the detailed answer →

90 Free trial → paid conversion rate changes across monthly cohorts

See the study guide for the detailed answer →

91 [Your question text]

See the study guide for the detailed answer →