A collection of SQL queries and insights analyzing employee and department data, showcasing aggregation, joins, window functions, and real-world business problem solving.
This project contains 38 SQL questions, including queries, joins, subqueries, window functions, CTEs, triggers, procedures, transactions, indexing, and views. It also includes business insights derived from the outputs.
-
Employees Table
- Stores employee info like department, salary, manager, and join date.
-
Projects Table
- Stores project assignments, hours worked, and rating.
- โ Basic Queries
- โ Joins (INNER, LEFT, RIGHT)
- โ Aggregations
- โ Subqueries
- โ Window Functions
- โ CTEs + Recursive CTEs
- โ Stored Functions
- โ Stored Procedures
- โ Transactions
- โ Triggers
- โ Views
- โ Indexing
- โ Case Statements
- โ Salary Categorization
- โ Performance Insights
-
- Employee Patterns
-
Highest Salary: Meera (95,000)
-
Second Highest Salary: Karan (90,000)
-
IT department has 3 employees โ highest count
-
Highest total hours: John (226 hours) across 4 projects
-
HR avg salary = 67,500 (Aisha < avg, Karan > avg)
-
IT avg salary = 75,000
-
Finance avg salary = 60,000
-
- Department-Level Insights
-
Department with highest total salary: IT (230,000 total salary)
-
Department with lowest headcount: Finance (1 employee)
-
High salary range (>80k): Meera & Karan
-
Medium salary range (50kโ80k): Majority employees
-
Low salary (<50k): None after updates
-
- Project Insights
-
Multiple high-performance projects: "ERP System", "E-Commerce", "Mobile App"
-
Most productive employee (hours): John
-
Ratings:
-
Excellent (>=8): 5 projects
-
Good (6โ7): 2 projects
-
-
Project distribution shows strong contribution from IT-related employees
-
- Managerial Structure
-
Managers:
-
Karan manages: Aisha & Riya
-
Meera manages: John & Sam
-
-
Trigger prevents deletion of managers to maintain hierarchy integrity
| Category | Questions |
|---|---|
| Basic Queries | Q1โQ7 |
| Self Join | Q9โQ10 |
| Window Functions | Q11โQ15 |
| Aggregations | Q16โQ18 |
| CTEs | Q19โQ20 |
| Functions | Q21โQ22 |
| Temporary Tables | Q23โQ24 |
| Procedures | Q25โQ26 |
| Triggers | Q27โQ28 |
| Transactions | Q29โQ30 |
| Views | Q31โQ32 |
| Indexing | Q33 |
| Business Case | Q35โQ38 |
๐งฎ Window Functions
-
Ranking
-
Running totals
-
Avg salary difference
-
LAG & LEAD
๐ Procedures & Functions
-
Annual salary calculation
-
Experience in years
-
Insert project procedure
-
Transaction-safe employee + project insertion
๐ Triggers
-
Logging deleted employees
-
Blocking deletion of managers
๐ Views
-
Employee project details
-
IT employees with salary > 60k
โก Indexing
- Improving performance by indexing join or filter columns
This SQL project proves your capability in:
- โ Real-world database problem solving
- โ Advanced SQL including transactions & triggers
- โ Creating structured business insights from raw queries
- โ Building production-level stored procedures & views
- โ Data analysis using aggregate + window functions
Bhupendra Shivhare
Aspiring Data Scientist | Deep Learning Enthusiast
LinkedIn: www.linkedin.com/in/bhupendra-shivhare-a8a02a25b
๐ง Email: shivharebhupendra@gmail.com