SQL25
The 25 SQL Questions That Build Real Data Analysts
Master the thinking patterns used by professional analysts daily
Table of Contents
TOC \h \o "1-3"
Introduction
If you're trying to break into data analytics, SQL is not just a tool—it's how
companies judge how you think with data.
Most beginners make one critical mistake: they try to memorize SQL syntax instead of
understanding
why queries are written the way they are.
These 25 questions are not random. They represent core thinking patterns used daily
by:
• Data Analysts
• Business Analysts
• Product Analysts
• Analytics Engineers
If you master these, you're not just interview-ready—you're job-ready.
What Interviewers REALLY Look For
When interviewers give SQL questions, they are not asking:
• "Do you know syntax?"
• "Have you seen this exact question before?"
They are asking:
1. Can you translate a business question into data logic?
2. Do you understand how tables relate to each other?
3. Can you reason about data quality and edge cases?
4. Do you think in metrics, not rows?
5. Can you explain your thinking clearly?
These 25 questions test all five.
Medium Level: Foundational Questions
Where Most Students Fail
These are non-negotiable. If you struggle here, interviews will feel overwhelming.
1. Find the Second Highest Salary
Why this matters in real jobs:
Ranking shows up everywhere—salaries, sales, engagement, performance.
What interviewers look for:
• Do you understand ties?
• Do you know the difference between ranking and aggregation?
💡 Key Insight: This question tests if you can reason beyond MAX().
2. Names Containing Letter 'a' Exactly Twice
Why this matters:
Data is messy. Text filtering must be precise.
What interviewers look for:
• Accuracy in pattern matching
• Logical filtering, not guesswork
💡 Key Insight: Precision > fancy SQL.
3. Retrieve Duplicate Records
Why this matters:
Real datasets always have duplicates—logs, transactions, CRM data.
What interviewers look for:
• Understanding what 'duplicate' actually means
• Clean grouping logic
💡 Key Insight: Data cleaning is 30–40% of a real analyst's job.
4. Running Total of Sales by Date
Why this matters:
Cumulative metrics power dashboards and reports.
What interviewers look for:
• Window function awareness
• Correct ordering logic
💡 Key Insight: This tests whether you think in time-series.
5. Employees Earning Above Department Average
Why this matters:
Almost all analytics compare individuals to baselines.
What interviewers look for:
• Group vs row-level thinking
• Correct use of subqueries or CTEs
💡 Key Insight: This is how KPIs are built.
6. Most Frequently Occurring Value
Why this matters:
Frequency analysis helps find dominant behaviors.
What interviewers look for:
• Aggregation + ordering
• Handling ties
7. Records from the Last 7 Days
Why this matters:
Most reports are time-bounded.
What interviewers look for:
• Correct date logic
• Boundary awareness
8. Employees Sharing the Same Salary
Why this matters:
Distribution analysis reveals patterns and anomalies.
What interviewers look for:
• Correct grouping
• Interpretation clarity
9. Top 3 Records Per Group
Why this matters:
This pattern is used in rankings, leaderboards, and reports.
What interviewers look for:
• Window function maturity
• Clean partition logic
10. Products Never Sold (LEFT JOIN)
Why this matters:
Identifying gaps is critical in analytics.
What interviewers look for:
• Join intuition
• Understanding NULL behavior
⚠️Critical: Weak joins = instant rejection.
Challenging Level: Thinking Like an Analyst
These questions test whether you can model real-world scenarios.
11. First Purchase in Last 6 Months
Why this matters:
Customer lifecycle analysis starts here.
What interviewers look for:
• Correct event definition
• Filtering in the right order
12. Pivot Rows into Columns
Why this matters:
Business teams expect pivoted reports.
What interviewers look for:
• Data reshaping skills
• Clean conditional logic
13. Month-over-Month Growth
Why this matters:
Growth metrics drive decisions.
What interviewers look for:
• Trend logic
• Correct handling of missing months
14. Median Salary
Why this matters:
Median is often more meaningful than average.
What interviewers look for:
• Statistical thinking
• Window function usage
15. Consecutive Login Days
Why this matters:
Retention analysis is core to product analytics.
What interviewers look for:
• Gaps-and-islands thinking
• Clear reasoning
16. Delete Duplicates Safely
Why this matters:
Bad deletes cause real damage.
What interviewers look for:
• Deterministic logic
• Safety mindset
17. Ratio Between Categories
Why this matters:
Ratios define performance comparisons.
What interviewers look for:
• Metric clarity
• Correct numerator/denominator
18. Recursive Hierarchy
Why this matters:
Org charts, category trees, folder structures.
What interviewers look for:
• Advanced SQL understanding
• Logical traversal
19. Gaps in Sequential Numbers
Why this matters:
Used in audits and pipeline checks.
What interviewers look for:
• LEAD/LAG mastery
• Edge case awareness
20. Split Comma-Separated Values
Why this matters:
Bad schemas exist in the real world.
What interviewers look for:
• Data cleaning mindset
• String manipulation skills
Advanced Level: What Makes You Stand Out
These questions demonstrate deep analytical thinking and advanced SQL proficiency.
21. Rank Products by Region
Why this matters:
Multi-dimensional analytics is common in companies.
22. Top 10% Earners Per Department
Why this matters:
Percentiles are used in compensation and performance analysis.
23. Business Hours Orders
Why this matters:
Operational analytics relies on time logic.
24. Weekday + Weekend Active Users
Why this matters:
Behavioral segmentation is a core analyst skill.
25. Customers Across 3+ Categories
Why this matters:
Cross-sell and diversification analysis.
How to Master These Questions
The Right Way to Practice
Don't just memorize solutions. Instead:
• Solve without memorizing: Understand the logic behind each query
• Explain every step out loud: If you can't explain it, you don't understand it
• Ask 'What could break this?': Think about edge cases and data quality issues
• Practice explaining like you're teaching someone: This builds communication
skills interviewers value
That's how analysts think.
Conclusion
If you master these 25 questions:
• SQL interviews stop feeling random
• You'll understand why queries work, not just how
• You'll think like a data analyst—not a query typist
The goal isn't to memorize 25 queries.
The goal is to internalize 5 thinking patterns that will serve you throughout your
entire analytics career:
6. Translating business questions into data logic
7. Understanding table relationships
8. Reasoning about data quality
9. Thinking in metrics
10. Explaining clearly
Good luck on your data analytics journey!