Welcome to the Leetcode-SQL-50 repository! This repository contains solutions to 50 SQL problems from Leetcode, carefully categorized based on different SQL concepts. It's designed as a resource for anyone looking to improve their SQL skills, whether you're a beginner or looking to refine your existing knowledge.
This repository is divided into several categories, each covering specific SQL concepts:
→ Advance Select and Joins: 7 Problems
→ Basic Aggregate Functions: 8 Problems
→ Basic Joins: 9 Problems
→ Select Statement: 5 Problems
→ Sorting and Grouping: 7 Problems
→ Subqueries: 7 Problems
→ Advanced String Functions / Regex / Clause: 7 Problems
Each folder contains SQL scripts for the respective problems, along with a brief description of the problem and the approach used to solve it.
The repository is organized as follows:
📦 Leetcode-SQL-50
┣ 📂 ADVANCE SELECT AND JOINS
┣ 📂 ADVANCED STRING FUNCTIONS / REGEX / CLAUSE
┣ 📂 BASIC AGGREGATE FUNCTIONS
┣ 📂 BASIC JOINS
┣ 📂 SELECT
┣ 📂 SORTING AND GROUPING
┗ 📂 SUBQUERIES
To use this repository:
1️⃣ Navigate to the folder that corresponds to the SQL concept you're interested in.
2️⃣ Open the SQL script file of the specific problem.
3️⃣ Run the SQL query in your preferred SQL environment (e.g., MySQL, PostgreSQL).
Each solution is accompanied by comments as well as Question(at line 101) too, to explain the approach and logic.
Here’s a quick glance at the key SQL concepts covered in this repository:
- Select Statements: Retrieve data from a database.
- Joins: Combine rows from two or more tables.
- Aggregation: Perform calculations on multiple rows to return a single value.
- Subqueries: Nested queries to filter and manipulate data.
- Sorting and Grouping: Organize data in a meaningful way.
- Structured Learning: Problems are categorized by SQL concepts, making it easy to focus on specific areas.
- Hands-On Practice: Improve your SQL skills by solving real-world problems.
- Quick Reference: Use the solutions as a reference when working on similar problems in the future.
Here are some ideas for expanding this repository:
- Add More Problems: Include more SQL problems, especially covering advanced concepts like window functions.
- Detailed Explanations: Add more comments or a markdown file to explain each solution in depth.
- Interactive Examples: Create a web interface to interact with the SQL queries directly.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.
Special thanks to LeetCode for providing such great problems to solve. This repository wouldn’t be possible without their resources.