Skip to content

VasuML07/sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

SQL Interview Preparation 🚀

Overview

A curated collection of SQL interview questions, solutions, explanations, and patterns commonly asked in top tech companies.

This repository is designed for:

  • Software Engineering Interviews
  • Data Analyst Interviews
  • Data Scientist Interviews
  • Business Intelligence Roles
  • Product Analytics Roles
  • FAANG & Top Product Companies

The goal is not just to memorize queries, but to understand the underlying concepts and develop strong SQL problem-solving skills.


Repository Structure

SQL/
│
├── 01-Basics/
├── 02-Filtering-Sorting/
├── 03-Aggregations/
├── 04-Joins/
├── 05-Subqueries/
├── 06-CTEs/
├── 07-Window-Functions/
├── 08-Date-Time/
├── 09-String-Functions/
├── 10-Case-Statements/
├── 11-Advanced-SQL/
├── 12-Interview-Questions/
├── 13-Real-World-Case-Studies/
└── Resources/

SQL Roadmap

Beginner

  • SELECT
  • WHERE
  • ORDER BY
  • LIMIT
  • DISTINCT
  • Aliases
  • Basic Functions

Intermediate

  • GROUP BY
  • HAVING
  • JOINS
  • UNION
  • CASE WHEN
  • Subqueries
  • CTEs

Advanced

  • Window Functions
  • Ranking Functions
  • Recursive CTEs
  • Query Optimization
  • Indexing
  • Execution Plans
  • Data Warehousing Concepts

Interview Patterns

1. Aggregations

Common Questions:

  • Second Highest Salary
  • Department Wise Salary
  • Top N Employees
  • Monthly Revenue

Key Concepts:

GROUP BY
HAVING
COUNT()
SUM()
AVG()
MIN()
MAX()

2. Joins

Types:

INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
SELF JOIN
CROSS JOIN

Frequently Asked:

  • Customers Without Orders
  • Employee Manager Relationship
  • Product Sales Analysis

3. Window Functions

Must Know:

ROW_NUMBER()
RANK()
DENSE_RANK()
LEAD()
LAG()
FIRST_VALUE()
LAST_VALUE()

FAANG Favorite Questions:

  • Nth Highest Salary
  • Consecutive Logins
  • Running Total
  • User Retention

4. CTEs

WITH cte AS (
    SELECT *
    FROM employees
)
SELECT *
FROM cte;

Used For:

  • Readability
  • Recursive Problems
  • Complex Analytics

5. Date & Time Problems

Frequently Tested:

  • DAU / MAU
  • Cohort Analysis
  • Retention Analysis
  • Monthly Revenue Growth

Functions:

DATE_ADD()
DATEDIFF()
EXTRACT()
DATE_TRUNC()
CURRENT_DATE

6. String Manipulation

Topics:

SUBSTRING()
CONCAT()
TRIM()
REPLACE()
LENGTH()
UPPER()
LOWER()

FAANG SQL Topics Checklist

  • SELECT
  • WHERE
  • ORDER BY
  • GROUP BY
  • HAVING
  • CASE WHEN
  • JOINS
  • UNION
  • Subqueries
  • CTEs
  • Window Functions
  • Recursive CTEs
  • Query Optimization
  • Indexing
  • Execution Plans
  • Data Modeling
  • Analytics SQL

Most Important SQL Interview Questions

Topic Difficulty
Second Highest Salary Easy
Nth Highest Salary Medium
Duplicate Records Easy
Consecutive Logins Medium
Running Total Medium
Department Top Earners Medium
Customer Retention Hard
Cohort Analysis Hard
Sessionization Hard
Funnel Analysis Hard

Company Wise Focus

Google

  • Window Functions
  • Analytics SQL
  • Product Metrics

Meta

  • User Retention
  • Funnels
  • Event Analysis

Amazon

  • Complex Joins
  • Aggregations
  • Business Metrics

Uber

  • Time Series Analysis
  • Geospatial Data
  • Marketplace Metrics

Airbnb

  • Booking Analytics
  • Ranking Problems
  • Experiment Analysis

Recommended Practice Order

  1. Basics
  2. Filtering & Sorting
  3. Aggregations
  4. Joins
  5. Subqueries
  6. CTEs
  7. Window Functions
  8. Advanced Analytics
  9. Mock Interviews

How To Use This Repository

  1. Learn the concept.
  2. Solve the problem without looking at the solution.
  3. Optimize the query.
  4. Compare alternative approaches.
  5. Review execution complexity.
  6. Revisit after one week.

Contributing

Contributions are welcome.

If you'd like to improve explanations, add optimized solutions, or include additional interview questions, feel free to open a Pull Request.


Connect

If this repository helped you:

⭐ Star the repository

🍴 Fork the repository

📢 Share it with fellow interview candidates


"SQL is not about writing queries. It's about extracting insights efficiently."

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors