Welcome to the Practice SQL: From Zero to Hero repository! This collection is designed to help individuals enhance their SQL skills through a series of exercises, each accompanied by schemas, questions, and solutions.
The repository is organized into directories for each exercise:
Practice-SQL-From-Zero-to-Hero/
├── SQL_exercise_01/
│ ├── SQL_exercise_01_schema_figure.png
│ ├── SQL_exercise_01_build_schema.sql
│ ├── SQL_exercise_01_questions_and_solutions.sql
│ └── ...
├── SQL_exercise_02/
│ ├── SQL_exercise_02_schema_figure.png
│ ├── SQL_exercise_02_build_schema.sql
│ ├── SQL_exercise_02_questions_and_solutions.sql
│ └── ...
├── SQL_exercise_03/
│ ├── SQL_exercise_03_schema_figure.png
│ ├── SQL_exercise_03_build_schema.sql
│ ├── SQL_exercise_03_questions_and_solutions.sql
│ └── ...
├── ...
└── SQL_exercise_10/
├── SQL_exercise_10_schema_figure.png
├── SQL_exercise_10_build_schema.sql
├── SQL_exercise_10_questions_and_solutions.sql
└── ...
Each exercise directory contains:
- Schema Diagram (
*_schema_figure.png
): Visual representation of the database schema. - Schema Build Script (
*_build_schema.sql
): SQL script to create the database schema. - Questions and Solutions (
*_questions_and_solutions.sql
): A set of SQL problems with their corresponding solutions.
- Exercise 01: Introduction to basic SQL queries.
- Exercise 02: Working with JOIN operations.
- Exercise 03: Exploring subqueries and nested queries.
- Exercise 04: Utilizing aggregate functions.
- Exercise 05: Implementing set operations.
- Exercise 06: Advanced JOIN techniques.
- Exercise 07: Window functions and analytical queries.
- Exercise 08: Handling complex subqueries.
- Exercise 09: Practical scenarios from real-world applications.
- Exercise 10: Advanced topics and optimization techniques.
Note: Exercises 1-8 are adapted from Wikibook SQL Exercises, with solutions provided by both the Wikibook and additional contributions. Exercises 9-10 are original problems inspired by practical experiences.
To get the most out of these exercises:
-
Clone the Repository:
git clone https://github.com/prayag-verma/Practice-SQL-From-Zero-to-Hero.git cd Practice-SQL-From-Zero-to-Hero
-
Set Up the Database:
- Use the
*_build_schema.sql
script in each exercise directory to create the necessary tables and insert data. - Execute the script in your SQL environment:
-- Example for Exercise 01 \i SQL_exercise_01/SQL_exercise_01_build_schema.sql
- Use the
-
Attempt the Questions:
- Open the
*_questions_and_solutions.sql
file. - Try to solve each question on your own before reviewing the provided solutions.
- Open the
👤 Prayag Verma
👥 Data Engineer
🔗 LinkedIn: → linkedin.com/in/prayagv
🔗 Portfolio: → prayagverma.com
💬 Feel free to raise an issue or contribute via pull requests!
Contributions are welcome! If you have additional exercises, improvements, or suggestions, please fork the repository and submit a pull request.
This project is licensed under the MIT License.