An open API service indexing awesome lists of open source software.

https://github.com/rakshitgupta9/leetcode-sql-50

This repo have solutions for the SQL-50 which are from leetcode
https://github.com/rakshitgupta9/leetcode-sql-50

leetcode leetcode-solutions leetcode-sql-50 leetcode-sql-solutions sql

Last synced: 14 days ago
JSON representation

This repo have solutions for the SQL-50 which are from leetcode

Awesome Lists containing this project

README

          

# Leetcode-SQL-50 Solutions

Welcome to the repository for the solutions to the top 50 SQL questions on LeetCode! This repository contains my solutions to the SQL problems listed in the [LeetCode Top SQL 50 Study Plan](https://leetcode.com/studyplan/top-sql-50/).

[My Leetcode](https://leetcode.com/u/rakshitgupta9/)

![image](https://github.com/user-attachments/assets/b1e13817-21a9-48d0-93d4-66227268501d)

## Table of Contents

- [Introduction](#introduction)
- [Solutions](#solutions)
- [Select](#select)
- [Basic Joins](#basic-joins)
- [Basic Aggregate Functions](#basic-aggregate-functions)
- [Sorting and Grouping](#sorting-and-grouping)
- [Advanced Select and Joins](#advanced-select-and-joins)
- [Subqueries](#subqueries)
- [Advanced String Functions / Regex / Clause](#advanced-string-functions-regex-clause)
- [Usage](#usage)
- [Contact](#contact)

## Introduction

This repository provides solutions to the top 50 SQL problems on LeetCode. Each problem is solved and the solution is provided in a SQL file. These problems cover various SQL concepts and are aimed at improving SQL querying skills.

## Solutions

The solutions are organized in the following structure:

### Select

- [Recyclable and Low Fat Products](./Select/Recyclable_and_Low_Fat_Products.sql)
- [Find Customer Referee](./Select/Find_Customer_Referee.sql)
- [Big Countries](./Select/Big_Countries.sql)
- [Article Views I](./Select/Article_Views_I.sql)
- [Invalid Tweets](./Select/Invalid_Tweets.sql)

### Basic Joins

- [Replace Employee ID With The Unique Identifier](./Basic_Joins/Replace_Employee_ID_With_The_Unique_Identifier.sql)
- [Product Sales Analysis I](./Basic_Joins/Product_Sales_Analysis_I.sql)
- [Customer Who Visited but Did Not Make Any Transactions](./Basic_Joins/Customer_Who_Visited_but_Did_Not_Make_Any_Transactions.sql)
- [Rising Temperature](./Basic_Joins/Rising_Temperature.sql)
- [Average Time of Process per Machine](./Basic_Joins/Average_Time_of_Process_per_Machine.sql)
- [Employee Bonus](./Basic_Joins/Employee_Bonus.sql)
- [Students and Examinations](./Basic_Joins/Students_and_Examinations.sql)
- [Managers with at Least 5 Direct Reports](./Basic_Joins/Managers_with_at_Least_5_Direct_Reports.sql)
- [Confirmation Rate](./Basic_Joins/Confirmation_Rate.sql)

### Basic Aggregate Functions

- [Not Boring Movies](./Basic_Aggregate_Functions/Not_Boring_Movies.sql)
- [Average Selling Price](./Basic_Aggregate_Functions/Average_Selling_Price.sql)
- [Project Employees I](./Basic_Aggregate_Functions/Project_Employees_I.sql)
- [Percentage of Users Attended a Contest](./Basic_Aggregate_Functions/Percentage_of_Users_Attended_a_Contest.sql)
- [Queries Quality and Percentage](./Basic_Aggregate_Functions/Queries_Quality_and_Percentage.sql)
- [Monthly Transactions I](./Basic_Aggregate_Functions/Monthly_Transactions_I.sql)
- [Immediate Food Delivery II](./Basic_Aggregate_Functions/Immediate_Food_Delivery_II.sql)
- [Game Play Analysis IV](./Basic_Aggregate_Functions/Game_Play_Analysis_IV.sql)

### Sorting and Grouping

- [Number of Unique Subjects Taught by Each Teacher](./Sorting_and_Grouping/Number_of_Unique_Subjects_Taught_by_Each_Teacher.sql)
- [User Activity for the Past 30 Days I](./Sorting_and_Grouping/User_Activity_for_the_Past_30_Days_I.sql)
- [Product Sales Analysis III](./Sorting_and_Grouping/Product_Sales_Analysis_III.sql)
- [Classes More Than 5 Students](./Sorting_and_Grouping/Classes_More_Than_5_Students.sql)
- [Find Followers Count](./Sorting_and_Grouping/Find_Followers_Count.sql)
- [Biggest Single Number](./Sorting_and_Grouping/Biggest_Single_Number.sql)
- [Customers Who Bought All Products](./Sorting_and_Grouping/Customers_Who_Bought_All_Products.sql)

### Advanced Select and Joins

- [The Number of Employees Which Report to Each Employee](./Advanced_Select_and_Joins/The_Number_of_Employees_Which_Report_to_Each_Employee.sql)
- [Primary Department for Each Employee](./Advanced_Select_and_Joins/Primary_Department_for_Each_Employee.sql)
- [Triangle Judgement](./Advanced_Select_and_Joins/Triangle_Judgement.sql)
- [Consecutive Numbers](./Advanced_Select_and_Joins/Consecutive_Numbers.sql)
- [Product Price at a Given Date](./Advanced_Select_and_Joins/Product_Price_at_a_Given_Date.sql)
- [Last Person to Fit in the Bus](./Advanced_Select_and_Joins/Last_Person_to_Fit_in_the_Bus.sql)
- [Count Salary Categories](./Advanced_Select_and_Joins/Count_Salary_Categories.sql)

### Subqueries

- [Employees Whose Manager Left the Company](./Subqueries/Employees_Whose_Manager_Left_the_Company.sql)
- [Exchange Seats](./Subqueries/Exchange_Seats.sql)
- [Movie Rating](./Subqueries/Movie_Rating.sql)
- [Restaurant Growth](./Subqueries/Restaurant_Growth.sql)
- [Friend Requests II: Who Has the Most Friends](./Subqueries/Friend_Requests_II_Who_Has_the_Most_Friends.sql)
- [Investments in 2016](./Subqueries/Investments_in_2016.sql)
- [Department Top Three Salaries](./Subqueries/Department_Top_Three_Salaries.sql)

### Advanced String Functions / Regex / Clause

- [Fix Names in a Table](./Advanced_String_Functions_Regex_Clause/Fix_Names_in_a_Table.sql)
- [Patients With a Condition](./Advanced_String_Functions_Regex_Clause/Patients_With_a_Condition.sql)
- [Delete Duplicate Emails](./Advanced_String_Functions_Regex_Clause/Delete_Duplicate_Emails.sql)
- [Second Highest Salary](./Advanced_String_Functions_Regex_Clause/Second_Highest_Salary.sql)
- [Group Sold Products By The Date](./Advanced_String_Functions_Regex_Clause/Group_Sold_Products_By_The_Date.sql)
- [List the Products Ordered in a Period](./Advanced_String_Functions_Regex_Clause/List_the_Products_Ordered_in_a_Period.sql)
- [Find Users With Valid E-Mails](./Advanced_String_Functions_Regex_Clause/Find_Users_With_Valid_E_Mails.sql)

## Usage

1. Clone this repository to your local machine:

```bash
git clone https://github.com/Rakshitgupta9/Leetcode-SQL-50.git
```

2. Navigate to the directory:

```bash
cd Leetcode-SQL-50
```

3. Open the SQL file for the problem you want to review.

You can run these SQL queries on your local SQL server or any SQL-based platform.

## Contact

If you have any questions or suggestions, feel free to reach out to me at:

- **Name**: [Rakshit Gupta](https://github.com/Rakshitgupta9/)
- **Email**: guptarakshit9858@gmail.com
- **LinkedIn**: [Rakshit Gupta](https://www.linkedin.com/in/rakshit9/)

Thank you for visiting this repository. Happy coding!