This repository contains a comprehensive collection of SQL queries focused on Subqueries and Window Functions, covering Beginner → Advanced level problems.
It is designed for:
- 📊 Data Analyst Interview Preparation
- 🏢 MNC SQL Coding Rounds
- 📚 Concept Mastery (Real-world Scenarios)
Database Name: parks_and_recreation
- employee_demographics
- employee_salary
- park_departments
- Single Row Subqueries
- Multi-row Subqueries (
IN,ANY,ALL) - Correlated Subqueries
- Nested Subqueries
- EXISTS / NOT EXISTS
- Aggregate Subqueries
ROW_NUMBER()RANK()vsDENSE_RANK()PARTITION BYLAG()&LEAD()FIRST_VALUE()&LAST_VALUE()NTILE()PERCENT_RANK()- Running calculations
- Trend analysis
- Find highest / lowest salary
- Employees above average salary
- Second highest salary
- Department-based filtering
- Nth highest salary
- Department-wise max/min salary
- Correlated subqueries
- Employee count per department
- Top N salaries (without window functions)
- Salary comparison using nested subqueries
- Duplicate detection
- Complex filtering using EXISTS
- Rank employees globally & department-wise
- Compare with department average
- Difference from average salary
- Salary increase/decrease detection
- Top N per department
- Percent contribution of salary
- Salary buckets using
NTILE()
🛠️ Skills Demonstrated
Advanced SQL Query Writing
Analytical Thinking
Real-world Data Analysis
Window Function Mastery
Performance-Oriented Query Design
🎯 Use Cases
Data Analyst Interviews
Business Intelligence Reporting
Salary & HR Analytics
Data Exploration Tasks
📌 Author
Shlok Singh
🎓 B.Tech CSE
💼 Aspiring Data Analyst
🧰 Skills: SQL, Excel, Advanced Excel, Power BI