π A comprehensive collection of solutions to the top 50 SQL problems on LeetCode. Each solution is written with clear explanations and best practices to help users master SQL queries, including SELECT, JOIN, GROUP BY, HAVING, window functions, and more. Perfect for beginners and those preparing for SQL interviews!
- π Well-documented SQL scripts for all 50 problems.
- π Easy-to-follow explanations for each query.
- β Solutions optimized for readability and efficiency.
- π― Covers beginner to intermediate SQL topics.
This repository contains solutions to the top 50 SQL problems on LeetCode, ranging from basic SELECT queries to more advanced JOINs and window functions. The solutions are designed to be beginner-friendly, with clear explanations of each concept and solution.
Whether you're preparing for SQL-based technical interviews or just want to improve your SQL skills, this repository will help you understand the most common SQL challenges and how to approach them efficiently.
Here is the list of the top 50 SQL problems solved in this repository:
- Combine Two Tables
- Second Highest Salary
- Rank Scores
- Reorder Data in Log Files
- Employees Earning More Than Their Managers
- Department Highest Salary
- Employees With a High Salary
- Deleting Records
- Patching Array
- Weather Observation Station 1
- Weather Observation Station 2
- Weather Observation Station 3
- Consecutive Numbers
- Not Boring Movies
- Average Salary Excluding the Minimum and Maximum Salary
- Employee Bonus
- Find the Developer's Name
- Total Sales Amount by Region
- Biggest Triangle Area
- Students and Examinations
- Duplicate Emails
- Find All Duplicates in an Array
- Group Anagrams
- Most Frequent Subtree Sum
- Intersection of Two Arrays
- Subdomain Visit Count
- Unique Email Addresses
- Find the City With the Smallest Number of Neighbors at a Threshold Distance
- Count Number of Nice Subarrays
- Find the Winner of an Array Game
- Sum of Unique Elements
- Rank of a Stream
- Reverse Rows in a Matrix
- Delete Duplicate Emails
- Count Substrings with Only One Distinct Letter
- Count Primes
- Find the City With the Smallest Number of Neighbors at a Threshold Distance
- Basic Calculator
- First Unique Character in a String
- Merge Intervals
- Palindrome Number
- Longest Substring Without Repeating Characters
- Valid Anagram
- Symmetric Tree
- Path Sum II
- Lowest Common Ancestor of a Binary Tree
- Linked List Cycle
- Palindrome Linked List
- Single Number
- Intersection of Two Arrays II
Each SQL problem has a corresponding solution located in a separate file. You can explore the solutions by browsing the repository or by following the table of contents above. Every solution comes with:
-
Clone the repository
-
Navigate to the directory containing the SQL files for each problem.
-
Open the relevant SQL file and study the solution and explanations provided.
-
You can execute the SQL queries on your local SQL environment or platforms like LeetCode to test and practice.
If you'd like to contribute to this repository, feel free to submit pull requests. Whether it's fixing a bug, optimizing a solution, or adding an additional explanation, your contributions are welcome!
To contribute:
-
Fork this repository.
-
Create a new branch for your changes.
-
Make the necessary changes.
-
Submit a pull request with a detailed description of your changes.
Happy Coding! β¨