This repository contains SQL solutions and practice problems from various coding platforms including HackerRank, LeetCode, and SQL-Practice. It serves as a comprehensive collection of SQL queries, problem solutions, and database practice exercises.
This repository is organized to help developers improve their SQL skills through practical problem-solving. Each SQL file contains solutions to specific database challenges, covering various SQL concepts and techniques.
The repository includes solutions for problems covering:
- Basic SQL Queries: SELECT, WHERE, ORDER BY, LIMIT
- Aggregation Functions: COUNT, SUM, AVG, MAX, MIN
- Joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN
- Subqueries and CTEs: Complex nested queries and Common Table Expressions
- Window Functions: ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD
- Data Manipulation: INSERT, UPDATE, DELETE, ALTER
- Advanced SQL: Recursive CTEs, Pivoting, Complex aggregations
The Hospital database contains medical-related tables for patient management, admissions, and medical records.
Key Tables:
- Patients information and demographics
- Medical admissions and discharges
- Diagnosis and treatment records
- Healthcare provider details
The NorthWind database represents a business application with sales, inventory, and customer management tables.
Key Tables:
- Products and categories
- Orders and order details
- Customers and suppliers
- Employees and territories
- Sales transactions
The repository contains SQL files named according to their problem numbers and descriptions:
- LeetCode Problems: Files with problem numbers (e.g.,
196. Delete Duplicate Emails.sql
) - HackerRank Problems: Various SQL challenges and practice problems
- Custom Practice: Patient management, weather observations, and other domain-specific queries
-
Clone the repository:
git clone <repository-url> cd SQL
-
Choose a problem category based on your learning goals
-
Review the SQL solutions to understand different approaches
-
Practice with your own database using the provided schemas
-
Modify queries to experiment with different SQL techniques
- Start with basic SELECT queries
- Practice WHERE clauses and filtering
- Learn basic aggregation functions
- Master JOIN operations
- Practice subqueries and CTEs
- Learn window functions
- Complex aggregations and pivoting
- Recursive queries
- Performance optimization techniques
To practice with the schemas shown in the images:
- Hospital Database: Set up a local database with patient management tables
- NorthWind Database: Use the standard NorthWind sample database available for most SQL platforms
- LeetCode: Algorithm and database problems
- HackerRank: SQL practice and certification
- SQL-Practice: Database-specific challenges
- Custom Problems: Real-world scenarios and practice cases
Feel free to contribute by:
- Adding new SQL solutions
- Improving existing queries
- Adding more database schemas
- Enhancing documentation
- Suggesting new problem categories
This repository is open source and available for educational purposes.
Happy SQL Learning! 🎯