Skip to content

This repository contains solutions to the first 50 SQL problems on LeetCode. Each problem is solved using SQL queries, with detailed explanations and efficient approaches. These solutions aim to help users improve their SQL skills and understanding of database concepts while providing clear and well-documented code for reference.

Notifications You must be signed in to change notification settings

MoreSangeet/LeetCode_SQL_50

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode SQL 50 Solutions

πŸš€ 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!

Features:

  • πŸ“ 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.

Table of Contents

  1. Introduction
  2. Problem List
  3. Solutions
  4. How to Use
  5. Contributing

Introduction

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.

Problem List

Here is the list of the top 50 SQL problems solved in this repository:

  1. Combine Two Tables
  2. Second Highest Salary
  3. Rank Scores
  4. Reorder Data in Log Files
  5. Employees Earning More Than Their Managers
  6. Department Highest Salary
  7. Employees With a High Salary
  8. Deleting Records
  9. Patching Array
  10. Weather Observation Station 1
  11. Weather Observation Station 2
  12. Weather Observation Station 3
  13. Consecutive Numbers
  14. Not Boring Movies
  15. Average Salary Excluding the Minimum and Maximum Salary
  16. Employee Bonus
  17. Find the Developer's Name
  18. Total Sales Amount by Region
  19. Biggest Triangle Area
  20. Students and Examinations
  21. Duplicate Emails
  22. Find All Duplicates in an Array
  23. Group Anagrams
  24. Most Frequent Subtree Sum
  25. Intersection of Two Arrays
  26. Subdomain Visit Count
  27. Unique Email Addresses
  28. Find the City With the Smallest Number of Neighbors at a Threshold Distance
  29. Count Number of Nice Subarrays
  30. Find the Winner of an Array Game
  31. Sum of Unique Elements
  32. Rank of a Stream
  33. Reverse Rows in a Matrix
  34. Delete Duplicate Emails
  35. Count Substrings with Only One Distinct Letter
  36. Count Primes
  37. Find the City With the Smallest Number of Neighbors at a Threshold Distance
  38. Basic Calculator
  39. First Unique Character in a String
  40. Merge Intervals
  41. Palindrome Number
  42. Longest Substring Without Repeating Characters
  43. Valid Anagram
  44. Symmetric Tree
  45. Path Sum II
  46. Lowest Common Ancestor of a Binary Tree
  47. Linked List Cycle
  48. Palindrome Linked List
  49. Single Number
  50. Intersection of Two Arrays II

Solutions

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:

How to Use

  1. Clone the repository

  2. Navigate to the directory containing the SQL files for each problem.

  3. Open the relevant SQL file and study the solution and explanations provided.

  4. You can execute the SQL queries on your local SQL environment or platforms like LeetCode to test and practice.

Contributing

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:

  1. Fork this repository.

  2. Create a new branch for your changes.

  3. Make the necessary changes.

  4. Submit a pull request with a detailed description of your changes.

Happy Coding! ✨

About

This repository contains solutions to the first 50 SQL problems on LeetCode. Each problem is solved using SQL queries, with detailed explanations and efficient approaches. These solutions aim to help users improve their SQL skills and understanding of database concepts while providing clear and well-documented code for reference.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published