🗃️
SQL
SQL Question Bank — Master Tracking File
🗃️
🗃️
SQL · Section 10 of 10

SQL Question Bank — Master Tracking File

🔒

This section is locked

Unlock every deep-dive, lab, mock interview, and memory map across all 10 topics.

View Plans — from ₹299/month

Already have a plan? Sign in

SQL Question Bank — Master Tracking File

💡 Interview Tip
HOW TO USE THIS FILE:
  • This is the SINGLE SOURCE OF TRUTH for all SQL interview questions
  • Every question has a Q# (never change old numbers, only append new ones)
  • Pattern# maps to the 15 patterns in the prep files
  • To ADD new questions: append rows at the bottom with the next Q#
  • To CLASSIFY a question you received in interview: match to the Pattern column

PATTERN REFERENCE (Quick Lookup)

P#Pattern NameKey SQL
P1Ranking / Top-N Per GroupROW_NUMBER, RANK, DENSE_RANK + PARTITION BY
P2Running Totals / CumulativeSUM() OVER (ORDER BY)
P3LAG / LEAD — Row-over-RowLAG(), LEAD()
P4Gaps & Islandsdate - ROW_NUMBER() island grouping
P5SessionizationLAG() gap detection + cumulative SUM as session_id
P6DeduplicationROW_NUMBER() PARTITION BY, keep rank = 1
P7Self-JoinSame table aliased twice
P8Cross Join — CombinationsCROSS JOIN for Cartesian product
P9Market Basket / Co-occurrenceSelf-join on order_id, item1 < item2
P10Conditional Aggregation / PivotSUM(CASE WHEN ...)
P11Cohort / Retention AnalysisMIN(event_date) as cohort + date offset
P12Date ArithmeticDATEDIFF, DATE_TRUNC, INTERVAL
P13Recursive CTEWITH RECURSIVE anchor + recursive step
P14Median / PercentilePERCENTILE_CONT or ROW_NUMBER median trick
P15Funnel AnalysisMulti-stage COUNT DISTINCT + conversion rate

FULL QUESTION BANK

Q#QuestionCompanyPatternDifficultySolved?
Q01Top 2 highest-grossing products within each category in 2022AmazonP1Medium
Q02Top 3 salaries in each departmentFAANG ClassicP1Medium
Q03Email activity rank per user (sent + received + spam, dense ranked)GoogleP1Medium
Q04Top 2 users per compan