Why "Company-Specific" SQL Questions Are Really Pattern-Specific
Candidates often search for "Amazon SQL interview questions" or "Meta SQL interview questions" hoping for a leaked question bank — but the more useful and durable truth is that large tech companies draw from the same handful of underlying patterns, just wrapped in different business contexts. An Amazon interviewer might frame a question around order fulfillment; a Meta interviewer might frame the identical underlying pattern around post engagement. Learn the patterns, not the surface wording, and you're prepared for all of them.
This guide organizes the recurring patterns seen across large tech company SQL interviews (based on the categories consistently reported by candidates across public interview-prep communities) and links to a full, worked guide for each.
Pattern 1: Ranking and Top-N
"Find the top 3 products by revenue in each category." "Find the second-highest-paid employee." "Find the most active user each week." This pattern tests whether you reach for the right window function (and specifically whether you handle ties correctly) rather than a slower correlated subquery or a broken GROUP BY + LIMIT attempt.
Master this with: Top N Per Group in SQL and Nth Highest Salary in SQL.
Pattern 2: User Behavior and Funnel Analytics
Extremely common at consumer product companies — "what percentage of users who viewed a product also completed checkout," "compute Day-7 retention," "build a cohort retention table." These questions test conditional aggregation and self-join-style comparisons across an events table, and they're some of the most business-relevant SQL a data analyst or product analytics role will actually write day to day.
Master this with: Product Analytics SQL Questions: Funnels, Retention, and Cohorts.
Pattern 3: Gaps, Streaks, and Consecutive Events
"Find users with a 5-day login streak." "Find the longest period a server was down." This pattern is a strong signal of window-function fluency because there's no single obvious query shape — you have to recognize the underlying "detect a break in a sequence" structure.
Master this with: The Gaps and Islands Problem in SQL.
Pattern 4: Hierarchical and Graph-Style Data
"Find every employee under a given manager, at any depth." "Compute the total cost of a manufactured product including all sub-components." These test recursive CTEs and self joins, and specifically whether you know when a single-level self join is insufficient.
Master this with: SQL Self Joins and Recursive CTEs Explained.
Pattern 5: Data Quality and Deduplication
"Find duplicate user records." "Deduplicate a table, keeping the most recent record per user." A staple at every company with any kind of ingestion pipeline, since real data is never as clean as interview datasets pretend.
Master this with: Find Duplicate Rows in SQL: 5 Ways.
Pattern 6: Schema Design and Query Optimization Judgment
More common in senior and staff-level loops — "how would you design this schema," "why is this query slow," "when would you denormalize this table." These test judgment and tradeoffs rather than a single correct query.
Master this with: SQL Query Optimization, SQL Indexes Explained, and Normalization vs. Denormalization.
How Interview Style Tends to Differ by Company Type
Based on patterns widely reported by candidates across interview-prep communities (not any confidential source), a rough generalization:
- Consumer product companies (social, e-commerce, streaming) tend to lean heavily on Pattern 2 (funnels, retention, engagement) since that's the daily reality of the analyst and data science roles being hired for.
- Infrastructure and cloud-platform companies tend to lean more on Pattern 6 (optimization, schema design, indexing judgment) for engineering-adjacent data roles.
- Logistics and marketplace companies often favor Pattern 1 and Pattern 3 (ranking, streaks, time-series patterns) given the operational nature of the data.
- Every company, regardless of type, tends to include at least one Pattern 5-style data-quality question, since it's a fast way to assess practical, defensive SQL habits.
Treat this as general orientation, not a guarantee — the safest strategy is always pattern fluency across all six, not betting on one company's typical style.
A Worked Example: One Question, Multiple "Company" Framings
The same underlying query — a Pattern 2 (funnel) problem — commonly appears reframed across different business contexts:
-- Generic funnel pattern: % of users completing each step
WITH funnel AS (
SELECT
user_id,
MAX(CASE WHEN event_name = 'viewed_item' THEN 1 ELSE 0 END) AS viewed,
MAX(CASE WHEN event_name = 'added_to_cart' THEN 1 ELSE 0 END) AS added,
MAX(CASE WHEN event_name = 'purchased' THEN 1 ELSE 0 END) AS purchased
FROM events
GROUP BY user_id
)
SELECT
SUM(viewed) AS viewed_count,
SUM(added) AS added_count,
SUM(purchased) AS purchased_count,
ROUND(100.0 * SUM(added) / NULLIF(SUM(viewed), 0), 1) AS view_to_cart_pct,
ROUND(100.0 * SUM(purchased) / NULLIF(SUM(added), 0), 1) AS cart_to_purchase_pct
FROM funnel;
Swap "viewed_item / added_to_cart / purchased" for "post_impression / like / comment," or "trial_started / upgraded / renewed," and you have the identical query shape behind an ad-engagement funnel or a subscription-conversion funnel. Recognizing this — out loud, in the interview — is exactly the signal pattern-based preparation is meant to produce.
How to Prepare Using a Pattern-Recognition Strategy
- Don't memorize specific queries — practice recognizing which of the six patterns above a new, unfamiliar question maps to
- For each pattern, be able to write the core query shape from memory, then adapt column and table names to the specific prompt
- Practice narrating your pattern recognition out loud: "this looks like a top-N-per-group problem, so I'll reach for ROW_NUMBER partitioned by category" — this is often worth more to an interviewer than the finished query itself
- Deliberately practice each pattern with intentionally messy data (ties, NULLs, duplicates, gaps) since that's exactly where interviewers probe deeper
Frequently Asked Questions
Should I memorize specific leaked interview questions?
It's an unreliable strategy — question banks rotate, and interviewers often adapt or invent variations specifically to defeat memorization. Pattern fluency transfers to any variation; memorized answers don't.
Do these patterns apply outside of "FAANG"-style companies?
Yes — these six patterns cover the large majority of SQL interview questions at any company that interviews for data analyst, data engineer, or backend roles involving relational databases, regardless of company size.
Practice All Six Patterns
Work through real, graded problems across every pattern with our SQL practice questions, or apply them end-to-end in a realistic business scenario with our case studies. Start with whichever pattern feels least familiar — that's usually the highest-leverage place to focus next.