Company-Wise SQL Interview Questions & Solutions (Part 2: Marketplaces, Fintech & Unicorns)
This article is available in English. Browse translated guides in the language menu.
While FAANG interviews focus heavily on core engagement and distributed storage scale, engineering loops at hyper-growth marketplaces, fintech rails, and logistics unicorns test operational real-time complexities:
- Marketplace Liquidity & Surge Dynamics (Uber, Airbnb, DoorDash)
- Financial Ledger Integrity, Idempotency & Gateway Drop-offs (Stripe, PayPal, PhonePe, Razorpay)
- Streaming Longevity & Graph Traversal (Spotify, LinkedIn, X / Twitter)
- High-Velocity E-Commerce & Flash Sale Spikes (Walmart, Flipkart, Swiggy, Zomato)
This guide provides 36 advanced, production-tested SQL problems with full schema definitions, optimized solutions, execution plans, and senior-level architectural trade-offs.
Navigation & Company Breakdown
- 1. Uber (Questions 37 to 39)
- 2. Airbnb (Questions 40 to 42)
- 3. DoorDash (Questions 43 to 45)
- 4. Stripe (Questions 46 to 48)
- 5. PayPal (Questions 49 to 51)
- 6. Spotify (Questions 52 to 54)
- 7. LinkedIn (Questions 55 to 57)
- 8. X / Twitter (Questions 58 to 60)
- 9. Walmart (Questions 61 to 63)
- 10. Flipkart (Questions 64 to 66)
- 11. Swiggy & Zomato (Questions 67 to 69)
- 12. PhonePe & Razorpay (Questions 70 to 72)
- Cross-Reference: Part 1 (FAANG & Enterprise Cloud)
1. Uber (Ride-Hailing & Logistics)
Uber tests temporal interval intersections, spatial supply-demand equilibrium, and driver asset utilization.
Question 37: Overlapping Driver Trips & Interval Collision Detection
- Company: Uber
- Difficulty: Hard
- Core Concepts: Temporal Collision, Non-Equi Joins, Interval Algebra
Scenario & Schema
A dispatch glitch may cause a driver to be assigned concurrent trips. Write a query to identify all pairs of conflicting trip IDs where a single driver had overlapping trips ($Trip_A \cap Trip_B \ne \emptyset$).
trips(trip_id BIGINT, driver_id INT, pickup_time TIMESTAMP, dropoff_time TIMESTAMP)
Solution
SELECT
t1.driver_id,
t1.trip_id AS trip_a_id,
t2.trip_id AS trip_b_id,
t1.pickup_time AS trip_a_pickup,
t1.dropoff_time AS trip_a_dropoff,
t2.pickup_time AS trip_b_pickup,
t2.dropoff_time AS trip_b_dropoff
FROM trips t1
JOIN trips t2
ON t1.driver_id = t2.driver_id
AND t1.trip_id < t2.trip_id
WHERE t1.pickup_time < t2.dropoff_time
AND t2.pickup_time < t1.dropoff_time
ORDER BY t1.driver_id, t1.pickup_time;
Why It Works & Architectural Mechanics
- Two intervals $[S_1, E_1]$ and $[S_2, E_2]$ overlap if and only if $S_1 < E_2 \land S_2 < E_1$.
t1.trip_id < t2.trip_idremoves self-matches and eliminates mirrored duplicates.- At scale, an exclusion constraint using PostgreSQL GiST indexes (
EXCLUDE USING gist (driver_id WITH =, tsrange(pickup_time, dropoff_time) WITH &&)) enforces this constraint physically at write time.
Question 38: Surge Multiplier Impact on Rider Cancellation Rates
- Company: Uber
- Difficulty: Medium
- Core Concepts: Conditional Aggregation, Price Elasticity, Spatial Hexagon Grouping
Scenario & Schema
Analyze whether price surge increases rider cancellations. Calculate the cancellation rate for surge rides ($\text{surge_multiplier} > 1.0$) vs non-surge rides ($\text{surge_multiplier} = 1.0$) across Uber H3 geo-hexagons.
ride_requests(request_id BIGINT, hex_id VARCHAR(15), surge_multiplier NUMERIC(3,2), status VARCHAR(20))
Solution
SELECT
hex_id,
COUNT(request_id) AS total_requests,
ROUND(
COUNT(CASE WHEN surge_multiplier > 1.0 AND status = 'rider_cancelled' THEN 1 END)::NUMERIC
/ NULLIF(COUNT(CASE WHEN surge_multiplier > 1.0 THEN 1 END), 0) * 100,
2
) AS surge_cancellation_pct,
ROUND(
COUNT(CASE WHEN surge_multiplier = 1.0 AND status = 'rider_cancelled' THEN 1 END)::NUMERIC
/ NULLIF(COUNT(CASE WHEN surge_multiplier = 1.0 THEN 1 END), 0) * 100,
2
) AS base_cancellation_pct
FROM ride_requests
GROUP BY hex_id
HAVING COUNT(request_id) >= 100
ORDER BY total_requests DESC;
Question 39: Driver Utilization Rate (On-Trip vs Online Hours)
- Company: Uber
- Difficulty: Hard
- Core Concepts: Ratio of Aggregates, Pre-aggregating Independent Dimensions
Scenario & Schema
Calculate each driver’s weekly utilization rate: $\frac{\text{Total Hours on Completed Trips}}{\text{Total Hours Logged Into the Driver App}}$.
driver_shifts(shift_id BIGINT, driver_id INT, online_time TIMESTAMP, offline_time TIMESTAMP)driver_trips(trip_id BIGINT, driver_id INT, pickup_time TIMESTAMP, dropoff_time TIMESTAMP, status VARCHAR(20))
Solution
WITH shift_durations AS (
SELECT
driver_id,
SUM(EXTRACT(EPOCH FROM (offline_time - online_time))) / 3600.0 AS total_online_hours
FROM driver_shifts
WHERE online_time >= '2026-10-01' AND offline_time < '2026-10-08'
GROUP BY driver_id
),
trip_durations AS (
SELECT
driver_id,
SUM(EXTRACT(EPOCH FROM (dropoff_time - pickup_time))) / 3600.0 AS total_trip_hours
FROM driver_trips
WHERE status = 'completed'
AND pickup_time >= '2026-10-01' AND dropoff_time < '2026-10-08'
GROUP BY driver_id
)
SELECT
s.driver_id,
ROUND(s.total_online_hours::NUMERIC, 2) AS online_hours,
ROUND(COALESCE(t.total_trip_hours, 0)::NUMERIC, 2) AS trip_hours,
ROUND((COALESCE(t.total_trip_hours, 0) / NULLIF(s.total_online_hours, 0)) * 100, 2) AS utilization_rate_pct
FROM shift_durations s
LEFT JOIN trip_durations t ON s.driver_id = t.driver_id
ORDER BY utilization_rate_pct DESC;
Why Separate CTEs are Mandatory
- Joining
driver_shiftsdirectly todriver_tripscauses a Cartesian fan-out whenever a driver has multiple shifts and multiple trips in the same week, artificially inflating totals.
2. Airbnb (Marketplace, Search, Host Dynamics)
Airbnb interviews emphasize booking conversion funnels, host SLA adherence, and calendar listing availability gaps.
Question 40: Multi-Step Guest Search-to-Booking Conversion Funnel
- Company: Airbnb
- Difficulty: Hard
- Core Concepts: Chronological Funnel, Session Attribution, Conditional Aggregation
Scenario & Schema
Track the 4-step guest conversion funnel within individual browsing sessions:
search -> view_listing -> request_to_book -> host_accepted.
Calculate the stage-over-stage conversion efficiency.
funnel_events(session_id VARCHAR(64), event_type VARCHAR(32), event_time TIMESTAMP)
Solution
WITH session_stages AS (
SELECT
session_id,
MIN(CASE WHEN event_type = 'search' THEN event_time END) AS search_t,
MIN(CASE WHEN event_type = 'view_listing' THEN event_time END) AS view_t,
MIN(CASE WHEN event_type = 'request_to_book' THEN event_time END) AS book_t,
MIN(CASE WHEN event_type = 'host_accepted' THEN event_time END) AS accept_t
FROM funnel_events
GROUP BY session_id
),
validated_stages AS (
SELECT
session_id,
search_t,
CASE WHEN view_t > search_t THEN view_t END AS valid_view,
CASE WHEN book_t > view_t AND view_t > search_t THEN book_t END AS valid_book,
CASE WHEN accept_t > book_t AND book_t > view_t AND view_t > search_t THEN accept_t END AS valid_accept
FROM session_stages
WHERE search_t IS NOT NULL
)
SELECT
COUNT(search_t) AS step_1_searches,
COUNT(valid_view) AS step_2_views,
COUNT(valid_book) AS step_3_requests,
COUNT(valid_accept) AS step_4_acceptances,
ROUND((COUNT(valid_view)::NUMERIC / NULLIF(COUNT(search_t), 0)) * 100, 2) AS search_to_view_pct,
ROUND((COUNT(valid_book)::NUMERIC / NULLIF(COUNT(valid_view), 0)) * 100, 2) AS view_to_request_pct,
ROUND((COUNT(valid_accept)::NUMERIC / NULLIF(COUNT(valid_book), 0)) * 100, 2) AS request_to_accept_pct
FROM validated_stages;
Question 41: Host Response Time SLA Classification
- Company: Airbnb
- Difficulty: Medium
- Core Concepts:
CASE WHEN, SLA Bucketing, Timestamp Arithmetic
Scenario & Schema
Airbnb categorizes hosts into response tiers based on how quickly they answer an initial guest inquiry:
< 1 hour:'Super Fast'1 to 12 hours:'Standard'12 to 24 hours:'Slow'> 24 hoursor unanswered:'Breached SLA'guest_inquiries(inquiry_id BIGINT, host_id INT, inquiry_sent_at TIMESTAMP, host_replied_at TIMESTAMP)
Solution
SELECT
host_id,
COUNT(inquiry_id) AS total_inquiries_received,
ROUND(
COUNT(CASE
WHEN host_replied_at <= inquiry_sent_at + INTERVAL '1 hour' THEN 1
END)::NUMERIC / COUNT(inquiry_id) * 100,
2
) AS super_fast_pct,
ROUND(
COUNT(CASE
WHEN host_replied_at IS NULL OR host_replied_at > inquiry_sent_at + INTERVAL '24 hours' THEN 1
END)::NUMERIC / COUNT(inquiry_id) * 100,
2
) AS breached_sla_pct
FROM guest_inquiries
GROUP BY host_id
HAVING COUNT(inquiry_id) >= 10
ORDER BY super_fast_pct DESC;
Question 42: Longest Consecutive Unbooked Availability Window
- Company: Airbnb
- Difficulty: Hard
- Core Concepts: Gaps and Islands, Date Displacements, Longest Streak
Scenario & Schema
For listing 12345, find the start date, end date, and duration (in days) of its longest consecutive unbooked availability block in 2026.
listing_calendar(listing_id INT, cal_date DATE, is_available BOOLEAN)
Solution
WITH island_markers AS (
SELECT
listing_id,
cal_date,
cal_date - (ROW_NUMBER() OVER (ORDER BY cal_date ASC) * INTERVAL '1 day') AS island_root
FROM listing_calendar
WHERE listing_id = 12345
AND is_available = TRUE
AND cal_date BETWEEN '2026-01-01' AND '2026-12-31'
),
available_streaks AS (
SELECT
listing_id,
island_root,
MIN(cal_date) AS streak_start,
MAX(cal_date) AS streak_end,
COUNT(*) AS available_days
FROM island_markers
GROUP BY listing_id, island_root
)
SELECT
streak_start,
streak_end,
available_days
FROM available_streaks
ORDER BY available_days DESC
LIMIT 1;
Why It Works: The Date Difference Island Trick
- Consecutive dates increment by 1 day at the same rate that
ROW_NUMBER()increments by 1. - Subtracting
ROW_NUMBER() * 1 dayfromcal_dateproduces a constantisland_rootdate for all contiguous days in that streak.
3. DoorDash (Logistics, Couriers, On-Time SLA)
DoorDash problems evaluate estimated vs actual delivery SLA breaches, courier batching pickup delays, and restaurant first-order attribution.
Question 43: Extremely Late Delivery Percentage by Restaurant Zone
- Company: DoorDash
- Difficulty: Medium
- Core Concepts: Conditional Aggregation, Date Part Extraction, Service Thresholds
Scenario & Schema
An “extremely late delivery” is defined as an order delivered more than 20 minutes past the estimated delivery time promised to the consumer. Calculate the percentage of extremely late deliveries per urban delivery zone.
deliveries(delivery_id BIGINT, zone_id INT, promised_delivery_time TIMESTAMP, actual_delivery_time TIMESTAMP)
Solution
SELECT
zone_id,
COUNT(delivery_id) AS total_deliveries,
COUNT(CASE
WHEN actual_delivery_time > promised_delivery_time + INTERVAL '20 minutes'
THEN 1
END) AS late_deliveries_count,
ROUND(
COUNT(CASE
WHEN actual_delivery_time > promised_delivery_time + INTERVAL '20 minutes'
THEN 1
END)::NUMERIC / COUNT(delivery_id) * 100,
2
) AS extremely_late_pct
FROM deliveries
WHERE actual_delivery_time IS NOT NULL
GROUP BY zone_id
HAVING COUNT(delivery_id) >= 50
ORDER BY extremely_late_pct DESC;
Question 44: First-Ever Restaurant Order Attribution & Lifetime Value
- Company: DoorDash
- Difficulty: Hard
- Core Concepts:
ROW_NUMBER() = 1, Join Aggregation, Merchant New Customer Acquisition
Scenario & Schema
For each restaurant merchant, count how many customers made their first-ever DoorDash platform order at that merchant, and calculate the average 90-day gross merchandise value (GMV) of those acquired customers.
orders(order_id BIGINT, customer_id BIGINT, restaurant_id INT, order_timestamp TIMESTAMP, order_amount NUMERIC(10,2))
Solution
WITH customer_first_orders AS (
SELECT
customer_id,
restaurant_id AS acquisition_restaurant_id,
order_timestamp AS first_order_time
FROM (
SELECT
customer_id,
restaurant_id,
order_timestamp,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_timestamp ASC) AS rn
FROM orders
) sub
WHERE rn = 1
),
subsequent_spending AS (
SELECT
f.acquisition_restaurant_id,
f.customer_id,
SUM(o.order_amount) AS customer_90d_gmv
FROM customer_first_orders f
JOIN orders o
ON f.customer_id = o.customer_id
AND o.order_timestamp BETWEEN f.first_order_time AND f.first_order_time + INTERVAL '90 days'
GROUP BY f.acquisition_restaurant_id, f.customer_id
)
SELECT
acquisition_restaurant_id AS restaurant_id,
COUNT(customer_id) AS new_customers_acquired,
ROUND(AVG(customer_90d_gmv), 2) AS avg_customer_90d_gmv
FROM subsequent_spending
GROUP BY acquisition_restaurant_id
ORDER BY new_customers_acquired DESC;
Question 45: Courier Merchant Pickup Wait Time (P90)
- Company: DoorDash
- Difficulty: Medium
- Core Concepts: Percentiles, Timestamp Delays, Courier Efficiency
Scenario & Schema
Calculate the 90th percentile wait time (in minutes) that Dasher couriers spend waiting at restaurants between dasher_arrived_at and food_picked_up_at.
pickup_events(order_id BIGINT, restaurant_id INT, dasher_arrived_at TIMESTAMP, food_picked_up_at TIMESTAMP)
Solution
WITH wait_times AS (
SELECT
restaurant_id,
EXTRACT(EPOCH FROM (food_picked_up_at - dasher_arrived_at)) / 60.0 AS wait_minutes
FROM pickup_events
WHERE food_picked_up_at >= dasher_arrived_at
)
SELECT
restaurant_id,
COUNT(*) AS total_pickups,
ROUND(PERCENTILE_CONT(0.90) WITHIN GROUP (ORDER BY wait_minutes)::NUMERIC, 2) AS p90_pickup_wait_minutes
FROM wait_times
GROUP BY restaurant_id
HAVING COUNT(*) >= 20
ORDER BY p90_pickup_wait_minutes DESC;
4. Stripe (Financial Rails, Ledgers, Risk Engine)
Stripe interviews evaluate immutable double-entry ledger reconstruction, card testing velocity detection, and MRR waterfall expansion/contraction.
Question 46: Running Ledger Account Balance with Deterministic Tie-Breaking
- Company: Stripe
- Difficulty: Hard
- Core Concepts: Cumulative Windows, Debit/Credit Balance Inversion, Tie-Breaking
Scenario & Schema
Given a financial ledger where credits increase the balance and debits decrease the balance, compute the point-in-time running balance for account 1001. Guarantee deterministic ordering even if multiple entries share identical timestamps.
ledger_entries(entry_id BIGINT, account_id INT, entry_type VARCHAR(6), amount NUMERIC(14,2), posted_at TIMESTAMP)
Solution
SELECT
entry_id,
posted_at,
entry_type,
amount,
SUM(
CASE
WHEN entry_type = 'credit' THEN amount
WHEN entry_type = 'debit' THEN -amount
ELSE 0
END
) OVER (
PARTITION BY account_id
ORDER BY posted_at ASC, entry_id ASC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS running_balance
FROM ledger_entries
WHERE account_id = 1001
ORDER BY posted_at ASC, entry_id ASC;
Why ORDER BY posted_at ASC, entry_id ASC is Critical
- Without the unique secondary tie-breaker
entry_id, two transactions posted at the identical microsecond could be processed in arbitrary order, producing non-deterministic running balances.
Question 47: Fraud Detection: Card Testing Velocity Spike
- Company: Stripe
- Difficulty: Hard
- Core Concepts: Sliding Time-Interval Self-Join, Security Abuse Prevention
Scenario & Schema
Identify fraud card-testing attacks: flag any card token that had 3 or more failed authorization attempts within a rolling 5-minute window followed by a successful charge.
charges(charge_id BIGINT, card_token VARCHAR(64), status VARCHAR(16), created_at TIMESTAMP)
Solution
WITH consecutive_failures AS (
SELECT
c_success.card_token,
c_success.charge_id AS successful_charge_id,
c_success.created_at AS success_time,
COUNT(c_fail.charge_id) AS failure_count_prior_5m
FROM charges c_success
JOIN charges c_fail
ON c_success.card_token = c_fail.card_token
AND c_fail.status = 'failed'
AND c_fail.created_at BETWEEN c_success.created_at - INTERVAL '5 minutes' AND c_success.created_at
WHERE c_success.status = 'succeeded'
GROUP BY c_success.card_token, c_success.charge_id, c_success.created_at
)
SELECT
card_token,
successful_charge_id,
success_time,
failure_count_prior_5m
FROM consecutive_failures
WHERE failure_count_prior_5m >= 3
ORDER BY success_time DESC;
Question 48: Monthly Recurring Revenue (MRR) Waterfall Breakdown
- Company: Stripe
- Difficulty: Hard
- Core Concepts: Financial Waterfall,
COALESCE, MoM Delta Classification
Scenario & Schema
Categorize subscription revenue change from May 2026 to June 2026 into 4 SaaS buckets:
New: Customer active in June, not in May.Expansion: Active in both, June revenue > May revenue.Contraction: Active in both, June revenue < May revenue.Churned: Active in May, cancelled in June ($0 revenue).
monthly_subscriptions(customer_id INT, billing_month DATE, mrr_amount NUMERIC(10,2))
Solution
WITH may_rev AS (
SELECT customer_id, mrr_amount AS rev_may
FROM monthly_subscriptions
WHERE billing_month = '2026-05-01'
),
june_rev AS (
SELECT customer_id, mrr_amount AS rev_june
FROM monthly_subscriptions
WHERE billing_month = '2026-06-01'
),
combined_tenants AS (
SELECT
COALESCE(m.customer_id, j.customer_id) AS customer_id,
COALESCE(m.rev_may, 0) AS rev_may,
COALESCE(j.rev_june, 0) AS rev_june
FROM may_rev m
FULL OUTER JOIN june_rev j ON m.customer_id = j.customer_id
)
SELECT
customer_id,
rev_may,
rev_june,
CASE
WHEN rev_may = 0 AND rev_june > 0 THEN 'New'
WHEN rev_may > 0 AND rev_june = 0 THEN 'Churned'
WHEN rev_june > rev_may THEN 'Expansion'
WHEN rev_june < rev_may THEN 'Contraction'
ELSE 'Unchanged'
END AS mrr_category,
(rev_june - rev_may) AS net_mrr_change
FROM combined_tenants
ORDER BY ABS(rev_june - rev_may) DESC;
5. PayPal (Payments, Wallets, Settlement)
PayPal tests merchant payout reconciliation, rapid-fire duplicate charge detection, and multi-currency FX cross-clearing.
Question 49: Merchant Payout Settlement Discrepancy Reconciliation
- Company: PayPal
- Difficulty: Hard
- Core Concepts: Full Outer Joins, Financial Settlement Audits, Discrepancy Matching
Scenario & Schema
Compare PayPal internal recorded merchant transactions against external automated clearing house (ACH) bank settlement files for 2026-10-15. Identify all transactions where amounts mismatch by more than $0.01 or exist on only one side.
paypal_txns(txn_id VARCHAR(32), merchant_id INT, amount NUMERIC(12,2))bank_settlements(bank_ref VARCHAR(32), merchant_id INT, settled_amount NUMERIC(12,2))
Solution
SELECT
COALESCE(p.txn_id, b.bank_ref) AS identifier,
COALESCE(p.merchant_id, b.merchant_id) AS merchant_id,
p.amount AS internal_recorded_amount,
b.settled_amount AS external_settled_amount,
CASE
WHEN p.txn_id IS NULL THEN 'Missing in PayPal Ledger'
WHEN b.bank_ref IS NULL THEN 'Missing in Bank ACH'
WHEN ABS(p.amount - b.settled_amount) > 0.01 THEN 'Amount Mismatch'
ELSE 'Matched'
END AS audit_status
FROM paypal_txns p
FULL OUTER JOIN bank_settlements b ON p.txn_id = b.bank_ref
WHERE p.txn_id IS NULL
OR b.bank_ref IS NULL
OR ABS(p.amount - b.settled_amount) > 0.01;
Question 50: Rapid-Succession Duplicate Payment Trap
- Company: PayPal
- Difficulty: Medium
- Core Concepts:
LAG(), Self-Collision, Fraud Detection
Scenario & Schema
Identify duplicate charges: transactions where the same user_id charged the identical amount to the identical merchant_id within 60 seconds of a preceding charge.
payments(payment_id BIGINT, user_id BIGINT, merchant_id INT, amount NUMERIC(10,2), payment_time TIMESTAMP)
Solution
WITH sequence_check AS (
SELECT
payment_id,
user_id,
merchant_id,
amount,
payment_time,
LAG(payment_time) OVER (
PARTITION BY user_id, merchant_id, amount
ORDER BY payment_time ASC
) AS prev_charge_time
FROM payments
)
SELECT
payment_id,
user_id,
merchant_id,
amount,
payment_time,
prev_charge_time,
EXTRACT(EPOCH FROM (payment_time - prev_charge_time)) AS seconds_delta
FROM sequence_check
WHERE prev_charge_time IS NOT NULL
AND payment_time - prev_charge_time <= INTERVAL '60 seconds'
ORDER BY payment_time DESC;
Question 51: Multi-Wallet Currency Arbitrage Audit
- Company: PayPal
- Difficulty: Hard
- Core Concepts: Circular Ledger Conversions, Arbitrage Exploitation
Scenario & Schema
Audit users who exploit FX slippage by converting Currency A -> Currency B -> Currency A within the same 1-hour window, gaining more than 1% net balance increase.
wallet_exchanges(exchange_id BIGINT, user_id BIGINT, from_currency VARCHAR(3), to_currency VARCHAR(3), from_amount NUMERIC(12,2), to_amount NUMERIC(12,2), exchange_time TIMESTAMP)
Solution
SELECT
e1.user_id,
e1.from_currency AS start_currency,
e1.to_currency AS intermediary_currency,
e1.from_amount AS original_investment,
e2.to_amount AS final_returned_amount,
ROUND(((e2.to_amount - e1.from_amount) / e1.from_amount) * 100, 2) AS arbitrage_gain_pct
FROM wallet_exchanges e1
JOIN wallet_exchanges e2
ON e1.user_id = e2.user_id
AND e1.to_currency = e2.from_currency
AND e1.from_currency = e2.to_currency
AND e2.exchange_time BETWEEN e1.exchange_time AND e1.exchange_time + INTERVAL '1 hour'
WHERE e2.to_amount > e1.from_amount * 1.01
ORDER BY arbitrage_gain_pct DESC;
6. Spotify (Audio Streaming, Charts, Recommendation)
Spotify problems test chart ranking streaks, early track skip rates, and genre listening diversity (entropy).
Question 52: Artists with Longest Consecutive Weeks in Top 10 Charts
- Company: Spotify
- Difficulty: Hard
- Core Concepts: Chart Longevity, Gaps and Islands on Weekly Calendars
Scenario & Schema
Find the longest consecutive streak of calendar weeks that each artist spent with at least one track inside the Spotify Weekly Top 10 Chart.
weekly_charts(chart_week DATE, artist_id INT, track_id INT, rank_position INT)
Solution
WITH top_10_weeks AS (
SELECT DISTINCT
artist_id,
chart_week
FROM weekly_charts
WHERE rank_position <= 10
),
streaks AS (
SELECT
artist_id,
chart_week,
chart_week - (ROW_NUMBER() OVER (PARTITION BY artist_id ORDER BY chart_week ASC) * INTERVAL '7 days') AS streak_group
FROM top_10_weeks
),
streak_lengths AS (
SELECT
artist_id,
streak_group,
MIN(chart_week) AS streak_start_week,
MAX(chart_week) AS streak_end_week,
COUNT(*) AS consecutive_weeks
FROM streaks
GROUP BY artist_id, streak_group
)
SELECT
artist_id,
MAX(consecutive_weeks) AS max_consecutive_top10_weeks
FROM streak_lengths
GROUP BY artist_id
ORDER BY max_consecutive_top10_weeks DESC;
Question 53: 30-Second Track Skip Rate by Playlist Position
- Company: Spotify
- Difficulty: Medium
- Core Concepts: Early Drop-off Metrics, Placement Ergonomics
Scenario & Schema
A skip is defined as listening to a song for less than 30 seconds. Calculate the skip rate for each track position index (position 1 to 10) across editorial playlists.
streams(stream_id BIGINT, playlist_id INT, track_position INT, seconds_played INT)
Solution
SELECT
track_position,
COUNT(stream_id) AS total_starts,
COUNT(CASE WHEN seconds_played < 30 THEN 1 END) AS skipped_streams,
ROUND(
COUNT(CASE WHEN seconds_played < 30 THEN 1 END)::NUMERIC
/ COUNT(stream_id) * 100,
2
) AS skip_rate_pct
FROM streams
WHERE track_position BETWEEN 1 AND 10
GROUP BY track_position
ORDER BY track_position ASC;
Question 54: User Listening Diversity (Information Entropy of Genres)
- Company: Spotify
- Difficulty: Hard
- Core Concepts: Shannon Entropy in SQL, Mathematical Aggregations
Scenario & Schema
Calculate the Shannon entropy of music genre consumption for user 888:
$H(X) = -\sum p_i \log_2(p_i)$
A higher entropy indicates diverse eclectic listening; an entropy near zero indicates a single genre listener.
user_genre_streams(user_id INT, genre VARCHAR(32), stream_count INT)
Solution
WITH genre_proportions AS (
SELECT
genre,
stream_count,
SUM(stream_count) OVER () AS total_streams,
stream_count::FLOAT / SUM(stream_count) OVER () AS p_i
FROM user_genre_streams
WHERE user_id = 888
)
SELECT
888 AS user_id,
ROUND(
(-SUM(p_i * (LN(p_i) / LN(2))))::NUMERIC,
4
) AS shannon_entropy_score
FROM genre_proportions;
7. LinkedIn (Professional Social Graph & Enterprise Talent)
LinkedIn tests recursive social graph traversal (2nd-degree connections), recruiting funnel attrition, and cross-company talent flow matrices.
Question 55: 2nd-Degree Connection Path Finder via Recursive CTE
- Company: LinkedIn
- Difficulty: Hard
- Core Concepts:
WITH RECURSIVE, Undirected Graph Traversal, Loop Prevention
Scenario & Schema
Given direct member connections, find all distinct 2nd-degree connections for user 1 (friends of friends who are not already direct friends of user 1, excluding user 1).
connections(user_id INT, friend_id INT)
Solution
WITH bidirectional AS (
SELECT user_id, friend_id FROM connections
UNION ALL
SELECT friend_id AS user_id, user_id AS friend_id FROM connections
),
direct_friends AS (
SELECT friend_id
FROM bidirectional
WHERE user_id = 1
),
second_degree AS (
SELECT
b2.friend_id AS second_degree_user_id
FROM direct_friends d
JOIN bidirectional b2
ON d.friend_id = b2.user_id
WHERE b2.friend_id != 1
AND b2.friend_id NOT IN (SELECT friend_id FROM direct_friends)
)
SELECT DISTINCT
second_degree_user_id
FROM second_degree
ORDER BY second_degree_user_id ASC;
Question 56: Job Application Drop-Off Rate by Employer Size Tier
- Company: LinkedIn
- Difficulty: Medium
- Core Concepts: Enterprise Dimension Join, Multi-stage Conversion
Scenario & Schema
Calculate the application completion rate ($\frac{\text{submitted}}{\text{viewed}}$) categorized by company headcount tier: Startup (1-50), Mid-Market (51-500), Enterprise (>500).
job_postings(job_id INT, company_id INT)companies(company_id INT, employee_count INT)job_events(event_id BIGINT, job_id INT, event_type VARCHAR(16))
Solution
WITH company_tiers AS (
SELECT
job_id,
CASE
WHEN c.employee_count <= 50 THEN 'Startup'
WHEN c.employee_count <= 500 THEN 'Mid-Market'
ELSE 'Enterprise'
END AS company_tier
FROM job_postings j
JOIN companies c ON j.company_id = c.company_id
)
SELECT
t.company_tier,
COUNT(CASE WHEN e.event_type = 'job_view' THEN 1 END) AS views_count,
COUNT(CASE WHEN e.event_type = 'application_submitted' THEN 1 END) AS applications_count,
ROUND(
COUNT(CASE WHEN e.event_type = 'application_submitted' THEN 1 END)::NUMERIC
/ NULLIF(COUNT(CASE WHEN e.event_type = 'job_view' THEN 1 END), 0) * 100,
2
) AS completion_rate_pct
FROM company_tiers t
JOIN job_events e ON t.job_id = e.job_id
GROUP BY t.company_tier
ORDER BY completion_rate_pct DESC;
Question 57: Talent Mobility Outflow/Inflow Matrix
- Company: LinkedIn
- Difficulty: Hard
- Core Concepts: State Transitions,
LEAD(), Career Trajectory Mapping
Scenario & Schema
Find the top 5 destination companies for software engineers leaving Google.
member_experience(member_id INT, company_name VARCHAR(64), start_date DATE, end_date DATE)
Solution
WITH career_transitions AS (
SELECT
member_id,
company_name AS prior_company,
LEAD(company_name) OVER (PARTITION BY member_id ORDER BY start_date ASC) AS next_company
FROM member_experience
)
SELECT
next_company AS destination_company,
COUNT(DISTINCT member_id) AS engineers_migrated_count
FROM career_transitions
WHERE prior_company = 'Google'
AND next_company IS NOT NULL
AND next_company != 'Google'
GROUP BY next_company
ORDER BY engineers_migrated_count DESC
LIMIT 5;
8. X / Twitter (Real-Time Streams & Telemetry)
X (formerly Twitter) questions test power-law frequency distributions (histograms of counts), rolling impression smoothing, and hashtag co-occurrence clustering.
Question 58: Tweet Frequency Distribution Histogram
- Company: X (Twitter)
- Difficulty: Medium
- Core Concepts: Double Aggregation, Power Law Binning, Histograms in SQL
Scenario & Schema
Construct a histogram of user activity: count how many users published exactly 1 tweet, 2 tweets, 3 tweets, etc., in 2026.
tweets(tweet_id BIGINT, user_id BIGINT, created_at TIMESTAMP)
Solution
WITH user_tweet_counts AS (
SELECT
user_id,
COUNT(tweet_id) AS tweet_count
FROM tweets
WHERE created_at >= '2026-01-01' AND created_at < '2027-01-01'
GROUP BY user_id
)
SELECT
tweet_count AS bucket_tweets_posted,
COUNT(user_id) AS total_users_in_bucket
FROM user_tweet_counts
GROUP BY tweet_count
ORDER BY bucket_tweets_posted ASC;
Question 59: 3-Day Rolling Average of Impressions with Outlier Clamping
- Company: X (Twitter)
- Difficulty: Hard
- Core Concepts: Window Framing, Clamping Mathematical Expressions, Smoothing
Scenario & Schema
Compute a 3-day rolling average of tweet impressions per creator, clamping any single daily value at 50,000 to prevent virality spikes from skewing the operational baseline.
daily_creator_metrics(creator_id BIGINT, metric_date DATE, impressions INT)
Solution
SELECT
creator_id,
metric_date,
impressions,
LEAST(impressions, 50000) AS clamped_impressions,
ROUND(
AVG(LEAST(impressions, 50000)) OVER (
PARTITION BY creator_id
ORDER BY metric_date ASC
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
),
2
) AS smoothed_3day_impressions
FROM daily_creator_metrics
ORDER BY creator_id, metric_date ASC;
Question 60: Hashtag Co-Occurrence Matrix
- Company: X (Twitter)
- Difficulty: Hard
- Core Concepts: Graph Matrix, Self-Joins, Pairwise Intersection
Scenario & Schema
Find the top 5 pairs of hashtags that appear together within the same tweet most frequently.
tweet_hashtags(tweet_id BIGINT, tag VARCHAR(64))
Solution
SELECT
h1.tag AS tag_a,
h2.tag AS tag_b,
COUNT(*) AS co_occurrence_count
FROM tweet_hashtags h1
JOIN tweet_hashtags h2
ON h1.tweet_id = h2.tweet_id
AND h1.tag < h2.tag
GROUP BY h1.tag, h2.tag
ORDER BY co_occurrence_count DESC
LIMIT 5;
9. Walmart (Omnichannel Supply Chain & Retail)
Walmart questions evaluate store-level out-of-stock latency, market basket association rules (Support & Confidence), and Same-Store Year-over-Year Comp Sales.
Question 61: Store-Level Out-of-Stock Duration & Replenishment Latency
- Company: Walmart
- Difficulty: Hard
- Core Concepts: Inventory Transitions,
LEAD(), Shelf Unavailability
Scenario & Schema
Calculate the average hours that retail item 999 remained out of stock before being replenished across regional supercenters.
inventory_logs(store_id INT, item_id INT, log_time TIMESTAMP, on_hand_qty INT)
Solution
WITH inventory_transitions AS (
SELECT
store_id,
log_time,
on_hand_qty,
LEAD(log_time) OVER (PARTITION BY store_id ORDER BY log_time ASC) AS next_log_time,
LEAD(on_hand_qty) OVER (PARTITION BY store_id ORDER BY log_time ASC) AS next_qty
FROM inventory_logs
WHERE item_id = 999
)
SELECT
store_id,
ROUND(
AVG(EXTRACT(EPOCH FROM (next_log_time - log_time)) / 3600.0)::NUMERIC,
2
) AS avg_stockout_duration_hours
FROM inventory_transitions
WHERE on_hand_qty = 0
AND next_qty > 0
GROUP BY store_id;
Question 62: Market Basket Association (Support & Confidence Rules)
- Company: Walmart
- Difficulty: Hard
- Core Concepts: Apriori Support & Confidence Metrics in SQL
Scenario & Schema
Calculate the Association Rule Confidence:
$$\text{Confidence}(Milk \to Cereal) = \frac{P(Milk \land Cereal)}{P(Milk)}$$
Given basket_items(basket_id BIGINT, product_name VARCHAR(64)).
Solution
WITH milk_baskets AS (
SELECT DISTINCT basket_id
FROM basket_items
WHERE product_name = 'Milk'
),
cereal_baskets AS (
SELECT DISTINCT basket_id
FROM basket_items
WHERE product_name = 'Cereal'
),
total_baskets AS (
SELECT COUNT(DISTINCT basket_id) AS total_baskets FROM basket_items
)
SELECT
(SELECT COUNT(*) FROM milk_baskets) AS milk_basket_count,
(SELECT COUNT(*) FROM cereal_baskets) AS cereal_basket_count,
COUNT(m.basket_id) AS milk_and_cereal_baskets,
ROUND(
(COUNT(m.basket_id)::NUMERIC / (SELECT COUNT(*) FROM milk_baskets)) * 100,
2
) AS confidence_milk_implies_cereal_pct
FROM milk_baskets m
JOIN cereal_baskets c ON m.basket_id = c.basket_id;
Question 63: Same-Store Comparable (Comp) Year-over-Year Sales
- Company: Walmart
- Difficulty: Medium
- Core Concepts: Comparable Store Exclusions, YoY Sales Delta
Scenario & Schema
Calculate Year-over-Year Comparable Store Sales Growth for stores that were continuously open throughout both 2025 and 2026.
stores(store_id INT, opened_date DATE)daily_store_sales(store_id INT, sale_date DATE, gross_amount NUMERIC(12,2))
Solution
WITH eligible_stores AS (
SELECT store_id
FROM stores
WHERE opened_date < '2025-01-01'
),
annual_store_sales AS (
SELECT
s.store_id,
EXTRACT(YEAR FROM s.sale_date)::INT AS sale_year,
SUM(s.gross_amount) AS total_sales
FROM daily_store_sales s
JOIN eligible_stores e ON s.store_id = e.store_id
WHERE s.sale_date BETWEEN '2025-01-01' AND '2026-12-31'
GROUP BY s.store_id, EXTRACT(YEAR FROM s.sale_date)
)
SELECT
y26.store_id,
y25.total_sales AS sales_2025,
y26.total_sales AS sales_2026,
ROUND(((y26.total_sales - y25.total_sales) / y25.total_sales) * 100, 2) AS comp_sales_growth_pct
FROM annual_store_sales y26
JOIN annual_store_sales y25
ON y26.store_id = y25.store_id
AND y26.sale_year = 2026
AND y25.sale_year = 2025
ORDER BY comp_sales_growth_pct DESC;
10. Flipkart (E-Commerce & Flash Sales)
Flipkart tests flash sale concurrency exhaustion, GMV quartiles, and regional logistics pin code SLA breaches.
Question 64: Big Billion Days Flash Sale Inventory Depletion Rate
- Company: Flipkart
- Difficulty: Hard
- Core Concepts: Running Deductions, Timestamp of Stock Exhaustion
Scenario & Schema
During a flash sale starting at 2026-10-01 00:00:00, product SKU-77 has an initial stock of 500 units. Write a query to find the exact timestamp of the order that depleted the inventory to 0.
orders(order_id BIGINT, sku_id VARCHAR(32), quantity INT, ordered_at TIMESTAMP)
Solution
WITH running_orders AS (
SELECT
order_id,
sku_id,
quantity,
ordered_at,
SUM(quantity) OVER (
PARTITION BY sku_id
ORDER BY ordered_at ASC, order_id ASC
) AS cumulative_qty_ordered
FROM orders
WHERE sku_id = 'SKU-77'
AND ordered_at >= '2026-10-01 00:00:00'
)
SELECT
order_id AS stockout_trigger_order_id,
ordered_at AS stockout_exact_timestamp,
cumulative_qty_ordered
FROM running_orders
WHERE cumulative_qty_ordered >= 500
ORDER BY cumulative_qty_ordered ASC
LIMIT 1;
Question 65: Customer Segmentation into GMV Quartiles (NTILE(4))
- Company: Flipkart
- Difficulty: Medium
- Core Concepts:
NTILE, RFM Segmentation, Percentile Grouping
Scenario & Schema
Assign active shoppers into 4 equal GMV quartiles (Quartile 1 = Platinum, Quartile 4 = Bronze) based on their total 2026 spend.
customer_spending(customer_id BIGINT, total_spend NUMERIC(12,2))
Solution
SELECT
customer_id,
total_spend,
NTILE(4) OVER (ORDER BY total_spend DESC) AS spend_quartile,
CASE NTILE(4) OVER (ORDER BY total_spend DESC)
WHEN 1 THEN 'Platinum'
WHEN 2 THEN 'Gold'
WHEN 3 THEN 'Silver'
WHEN 4 THEN 'Bronze'
END AS tier_name
FROM customer_spending;
Question 66: Regional Logistics Delivery SLA Breach by Pin Code
- Company: Flipkart
- Difficulty: Medium
- Core Concepts: Aggregation, Geo-Delivery Performance, SLA Thresholds
Scenario & Schema
Find destination postal pin codes where more than 15% of Ekart deliveries exceeded the 4-day delivery promise in Q3 2026.
shipments(tracking_id BIGINT, pin_code VARCHAR(10), dispatched_date DATE, delivery_date DATE)
Solution
SELECT
pin_code,
COUNT(tracking_id) AS total_shipments,
COUNT(CASE WHEN delivery_date - dispatched_date > 4 THEN 1 END) AS breached_shipments,
ROUND(
COUNT(CASE WHEN delivery_date - dispatched_date > 4 THEN 1 END)::NUMERIC
/ COUNT(tracking_id) * 100,
2
) AS breach_rate_pct
FROM shipments
WHERE dispatched_date BETWEEN '2026-07-01' AND '2026-09-30'
GROUP BY pin_code
HAVING COUNT(tracking_id) >= 100
AND (COUNT(CASE WHEN delivery_date - dispatched_date > 4 THEN 1 END)::NUMERIC / COUNT(tracking_id)) > 0.15
ORDER BY breach_rate_pct DESC;
11. Swiggy & Zomato (Food Delivery & Quick-Commerce)
Swiggy and Zomato evaluate habit formation time-to-second-order, restaurant revenue milestone dates, and delivery partner idle time.
Question 67: Customer Time-to-Second-Order Velocity (Habit Formation)
- Company: Swiggy & Zomato
- Difficulty: Medium
- Core Concepts: Window Functions, Retention Velocity, Day Differences
Scenario & Schema
Calculate the average days elapsed between a customer’s first completed order and their second completed order.
food_orders(order_id BIGINT, customer_id BIGINT, order_time TIMESTAMP, status VARCHAR(20))
Solution
WITH customer_order_history AS (
SELECT
customer_id,
order_time,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_time ASC) AS order_sequence
FROM food_orders
WHERE status = 'delivered'
)
SELECT
ROUND(
AVG(EXTRACT(EPOCH FROM (o2.order_time - o1.order_time)) / 86400.0)::NUMERIC,
2
) AS avg_days_to_second_order
FROM customer_order_history o1
JOIN customer_order_history o2
ON o1.customer_id = o2.customer_id
AND o1.order_sequence = 1
AND o2.order_sequence = 2;
Question 68: Restaurant Cumulative Revenue Milestone Date Tracker
- Company: Swiggy & Zomato
- Difficulty: Hard
- Core Concepts: Running Accumulator, Earliest Milestone Threshold
Scenario & Schema
Find the exact calendar date on which each new restaurant partner surpassed ₹5,00,000 in cumulative GMV.
restaurant_sales(restaurant_id INT, sale_date DATE, daily_gmv NUMERIC(10,2))
Solution
WITH cumulative_sales AS (
SELECT
restaurant_id,
sale_date,
daily_gmv,
SUM(daily_gmv) OVER (
PARTITION BY restaurant_id
ORDER BY sale_date ASC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS running_gmv
FROM restaurant_sales
),
milestone_hits AS (
SELECT
restaurant_id,
sale_date,
running_gmv,
ROW_NUMBER() OVER (PARTITION BY restaurant_id ORDER BY sale_date ASC) AS rn
FROM cumulative_sales
WHERE running_gmv >= 500000
)
SELECT
restaurant_id,
sale_date AS milestone_date,
running_gmv AS exact_gmv_on_milestone_date
FROM milestone_hits
WHERE rn = 1
ORDER BY milestone_date ASC;
Question 69: Delivery Fleet Idle Time vs Transit Time Efficiency
- Company: Swiggy & Zomato
- Difficulty: Hard
- Core Concepts: Temporal Gaps Between Trips, Fleet Logistics
Scenario & Schema
Calculate the average minutes a delivery partner waits idle between completing one delivery and accepting their next assignment.
delivery_trips(trip_id BIGINT, rider_id INT, accepted_at TIMESTAMP, delivered_at TIMESTAMP)
Solution
WITH trip_chronology AS (
SELECT
rider_id,
delivered_at,
LEAD(accepted_at) OVER (PARTITION BY rider_id ORDER BY accepted_at ASC) AS next_accepted_at
FROM delivery_trips
)
SELECT
rider_id,
COUNT(*) AS total_consecutive_trips,
ROUND(
AVG(EXTRACT(EPOCH FROM (next_accepted_at - delivered_at)) / 60.0)::NUMERIC,
2
) AS avg_idle_wait_minutes
FROM trip_chronology
WHERE next_accepted_at IS NOT NULL
AND next_accepted_at >= delivered_at
GROUP BY rider_id
HAVING COUNT(*) >= 10
ORDER BY avg_idle_wait_minutes ASC;
12. PhonePe & Razorpay (UPI, Payment Gateways & Fintech)
PhonePe and Razorpay problems evaluate real-time payment gateway degradation alerts, UPI VPA consecutive failure streaks, and merchant MoM churn volume differentials.
Question 70: Real-Time Payment Gateway Success Rate Degradation Alert
- Company: PhonePe & Razorpay
- Difficulty: Hard
- Core Concepts: Time Windows, Gateway Reliability, SLA Alerting
Scenario & Schema
Every 5 minutes, monitor payment gateway performance: flag any gateway whose transaction success rate dropped below 85% during the last 15 minutes (with at least 100 transactions).
gateway_transactions(txn_id BIGINT, gateway_name VARCHAR(32), status VARCHAR(16), created_at TIMESTAMP)
Solution
SELECT
gateway_name,
COUNT(txn_id) AS total_attempts,
COUNT(CASE WHEN status = 'SUCCESS' THEN 1 END) AS successful_txns,
ROUND(
(COUNT(CASE WHEN status = 'SUCCESS' THEN 1 END)::NUMERIC / COUNT(txn_id)) * 100,
2
) AS success_rate_pct
FROM gateway_transactions
WHERE created_at >= NOW() - INTERVAL '15 minutes'
GROUP BY gateway_name
HAVING COUNT(txn_id) >= 100
AND (COUNT(CASE WHEN status = 'SUCCESS' THEN 1 END)::NUMERIC / COUNT(txn_id)) < 0.85
ORDER BY success_rate_pct ASC;
Question 71: Consecutive Failure Streaks & Terminal Error Isolation
- Company: PhonePe & Razorpay
- Difficulty: Hard
- Core Concepts: Gaps and Islands, Failure Run Length, Error Diagnostics
Scenario & Schema
Identify bank UPI handles (@okhdfcbank, @ybl, @icici) that suffered 5 or more consecutive failed transactions today.
upi_transactions(txn_id BIGINT, handle VARCHAR(32), status VARCHAR(16), txn_time TIMESTAMP)
Solution
WITH flagged_runs AS (
SELECT
txn_id,
handle,
status,
txn_time,
CASE
WHEN status = 'FAILED'
AND LAG(status) OVER (PARTITION BY handle ORDER BY txn_time ASC) = 'FAILED'
THEN 0
ELSE 1
END AS is_streak_change
FROM upi_transactions
WHERE txn_time >= CURRENT_DATE
),
streak_groups AS (
SELECT
txn_id,
handle,
status,
txn_time,
SUM(is_streak_change) OVER (PARTITION BY handle ORDER BY txn_time ASC) AS streak_group_id
FROM flagged_runs
),
streak_counts AS (
SELECT
handle,
streak_group_id,
status,
MIN(txn_time) AS streak_start,
MAX(txn_time) AS streak_end,
COUNT(*) AS consecutive_run_count
FROM streak_groups
WHERE status = 'FAILED'
GROUP BY handle, streak_group_id, status
)
SELECT
handle,
streak_start,
streak_end,
consecutive_run_count
FROM streak_counts
WHERE consecutive_run_count >= 5
ORDER BY consecutive_run_count DESC;
Question 72: Active vs Churned Merchant MoM Volume Differential
- Company: PhonePe & Razorpay
- Difficulty: Hard
- Core Concepts: Full Outer Joins, Financial Retention, MoM Settlement Delta
Scenario & Schema
Find merchants who transacted in September 2026 but either completely churned ($0 volume) in October 2026, or whose processing volume dropped by more than 50%.
merchant_daily_volumes(merchant_id INT, txn_date DATE, settled_volume NUMERIC(14,2))
Solution
WITH sep_volumes AS (
SELECT
merchant_id,
SUM(settled_volume) AS vol_sep
FROM merchant_daily_volumes
WHERE txn_date >= '2026-09-01' AND txn_date < '2026-10-01'
GROUP BY merchant_id
),
oct_volumes AS (
SELECT
merchant_id,
SUM(settled_volume) AS vol_oct
FROM merchant_daily_volumes
WHERE txn_date >= '2026-10-01' AND txn_date < '2026-11-01'
GROUP BY merchant_id
)
SELECT
s.merchant_id,
s.vol_sep,
COALESCE(o.vol_oct, 0) AS vol_oct,
ROUND(
((COALESCE(o.vol_oct, 0) - s.vol_sep) / s.vol_sep) * 100,
2
) AS volume_change_pct
FROM sep_volumes s
LEFT JOIN oct_volumes o ON s.merchant_id = o.merchant_id
WHERE COALESCE(o.vol_oct, 0) < (s.vol_sep * 0.50)
ORDER BY s.vol_sep DESC;
Review Part 1 & Interactive Challenges
Make sure to also master Company-Wise SQL Interview Questions (Part 1: FAANG & Enterprise Giants), covering:
- Meta: DAU/MAU stickiness, ad-click attribution lag, mutual friend intersections, and multi-stage funnels.
- Amazon: MoM category revenue, left anti-joins with NULL safety, moving replenishment, and P95 latencies.
- Google: 30-minute sessionization, multi-touch ad attribution, Z-Score spend anomalies, and query n-grams.
- Microsoft: Continuous calendar scaffolding, Teams audio concurrency running totals, and recursive org charts.
- Apple: App Store tie preservation, hardware affinity analysis, and decay-weighted ratings.
- Netflix: Binge-watching interval stitching, A/B variant conversions, and churn attribution.
Hands-On Interactive Practice on SQLMaster:
- Confirmation Rate (Fintech & Marketplace Conversions)
- Monthly Transactions I (Financial Ledger Aggregation)
- Immediate Food Delivery II (Order Logistics Analytics)
- Product Price at a Given Date (Temporal Price Lookups)
- Last Person to Fit in the Bus (Running Capacity Calculations)
- Explore All Top 50 SQL Interview Challenges
Ready to Level Up Your SQL?
Don't just read about databases. Write queries, build schemas, and practice real-world interview questions interactively.