Skip to content

About

A complete guide to LeetCode SQL 50 with handwritten notes, visual explanations, and optimal solutions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

31 Commits

Folders and files

Repository files navigation

LeetCode SQL 50 - Solutions and Notes

A day-by-day record of solving the LeetCode SQL 50 study plan in MySQL,
with a clear explanation, a clean query and revision notes for every problem.

MySQL LeetCode Progress 28/50 Status

Star this repository


Table of Contents

  1. About
  2. Progress Overview
  3. Daily Solutions
  4. Full Problem List
  5. What Each Notes File Contains
  6. Repository Structure
  7. Core SQL Concepts Covered
  8. How to Use This Repository
  9. Author

About

This repository tracks my progress through the LeetCode SQL 50 study plan. One problem is solved and documented every day. The goal is not only to get an Accepted verdict, but to understand why the query works, so that the same idea can be rebuilt from scratch in an interview.

Every problem includes:

  • The problem statement and a worked example
  • A real-life analogy to build intuition
  • A step-by-step build-up of the query
  • The final accepted query
  • Common mistakes and interview tips

This repository is updated daily.


Progress Overview

Overall: 28 of 50 problems solved (56%)

Category Solved Total Status
01. Select 5 5 Complete
02. Basic Joins 9 9 Complete
03. Basic Aggregate Functions 8 8 Complete
04. Sorting and Grouping 6 7 In progress
05. Advanced Select and Joins 0 7 Not started
06. Subqueries 0 7 Not started
07. Advanced String Functions / Regex / Clause 0 7 Not started

By difficulty

Difficulty Solved Total
Easy 22 32
Medium 6 17
Hard 0 1

Daily Solutions

Day Problem Difficulty Category Notes
1 1757. Recyclable and Low Fat Products Easy Select View
2 584. Find Customer Referee Easy Select View
3 595. Big Countries Easy Select View
4 1148. Article Views I Easy Select View
5 1683. Invalid Tweets Easy Select View
6 1378. Replace Employee ID With The Unique Identifier Easy Basic Joins View
7 1068. Product Sales Analysis I Easy Basic Joins View
8 1581. Customer Who Visited but Did Not Make Any Transactions Easy Basic Joins View
9 197. Rising Temperature Easy Basic Joins View
10 1661. Average Time of Process per Machine Easy Basic Joins View
11 577. Employee Bonus Easy Basic Joins View
12 1280. Students and Examinations Easy Basic Joins View
13 570. Managers with at Least 5 Direct Reports Medium Basic Joins View
14 1934. Confirmation Rate Medium Basic Joins View
15 620. Not Boring Movies Easy Basic Aggregate Functions View
16 1251. Average Selling Price Easy Basic Aggregate Functions View
17 1075. Project Employees I Easy Basic Aggregate Functions View
18 1633. Percentage of Users Attended a Contest Easy Basic Aggregate Functions View
19 1211. Queries Quality and Percentage Easy Basic Aggregate Functions View
20 1193. Monthly Transactions I Medium Basic Aggregate Functions View
21 1174. Immediate Food Delivery II Medium Basic Aggregate Functions View
22 550. Game Play Analysis IV Medium Basic Aggregate Functions View
23 2356. Number of Unique Subjects Taught by Each Teacher Easy Sorting and Grouping View
24 1141. User Activity for the Past 30 Days I Easy Sorting and Grouping View
25 1070. Product Sales Analysis III Medium Sorting and Grouping View
26 596. Classes With at Least 5 Students Easy Sorting and Grouping View
27 1729. Find Followers Count Easy Sorting and Grouping View
28 619. Biggest Single Number Easy Sorting and Grouping View

Full Problem List

01. Select

  • 1757. Recyclable and Low Fat Products
  • 584. Find Customer Referee
  • 595. Big Countries
  • 1148. Article Views I
  • 1683. Invalid Tweets

02. Basic Joins

  • 1378. Replace Employee ID With The Unique Identifier
  • 1068. Product Sales Analysis I
  • 1581. Customer Who Visited but Did Not Make Any Transactions
  • 197. Rising Temperature
  • 1661. Average Time of Process per Machine
  • 577. Employee Bonus
  • 1280. Students and Examinations
  • 570. Managers with at Least 5 Direct Reports
  • 1934. Confirmation Rate

03. Basic Aggregate Functions

  • 620. Not Boring Movies
  • 1251. Average Selling Price
  • 1075. Project Employees I
  • 1633. Percentage of Users Attended a Contest
  • 1211. Queries Quality and Percentage
  • 1193. Monthly Transactions I
  • 1174. Immediate Food Delivery II
  • 550. Game Play Analysis IV

04. Sorting and Grouping

  • 2356. Number of Unique Subjects Taught by Each Teacher
  • 1141. User Activity for the Past 30 Days I
  • 1070. Product Sales Analysis III
  • 596. Classes With at Least 5 Students
  • 1729. Find Followers Count
  • 619. Biggest Single Number
  • 1045. Customers Who Bought All Products

05. Advanced Select and Joins

  • 1731. The Number of Employees Which Report to Each Employee
  • 1789. Primary Department for Each Employee
  • 610. Triangle Judgement
  • 180. Consecutive Numbers
  • 1164. Product Price at a Given Date
  • 1204. Last Person to Fit in the Bus
  • 1907. Count Salary Categories

06. Subqueries

  • 1978. Employees Whose Manager Left the Company
  • 626. Exchange Seats
  • 1341. Movie Rating
  • 1321. Restaurant Growth
  • 602. Friend Requests II: Who Has the Most Friends
  • 585. Investments in 2016
  • 185. Department Top Three Salaries

07. Advanced String Functions / Regex / Clause

  • 1667. Fix Names in a Table
  • 1527. Patients With a Condition
  • 196. Delete Duplicate Emails
  • 176. Second Highest Salary
  • 1484. Group Sold Products By The Date
  • 1327. List the Products Ordered in a Period
  • 1517. Find Users With Valid E-Mails

What Each Notes File Contains

Every dayN.md file follows the same layout, so any problem can be revised quickly:

Section Purpose
Header Difficulty, topic, LeetCode link, date solved, runtime and status
Problem Statement Table schema and the task, restated clearly
Real-Life Analogy A simple picture to build intuition before writing SQL
Example Walkthrough Input and output traced by hand
Step-by-Step Build The query built up one clause at a time
Final Query The accepted solution
Key Concepts The SQL ideas the problem tests
Common Mistakes Errors worth remembering
Interview Tips How to recognize and explain this pattern

Repository Structure

LeetCode-SQL-50-Solutions/
|-- README.md
|-- Day1/
|   |-- day1.md
|-- Day2/
|   |-- day2.md
|-- ...
|-- Day28/
    |-- day28.md

Core SQL Concepts Covered

Concept Where it appears
SELECT, WHERE, filtering rows Select
JOIN (inner, left), self join Basic Joins
GROUP BY with COUNT, SUM, AVG, MAX Basic Aggregate Functions, Sorting and Grouping
HAVING (filtering after grouping) Sorting and Grouping
ORDER BY, DISTINCT Sorting and Grouping
Subqueries in FROM (derived tables) Sorting and Grouping, Subqueries
NULL handling with aggregates Sorting and Grouping

SQL logical execution order, used throughout the notes:

FROM -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY -> LIMIT

How to Use This Repository

  1. Open the Daily Solutions table and pick a problem.
  2. Read the notes file for that day, up to the Step-by-Step Build section.
  3. Try to write the query yourself on LeetCode before looking at the final query.
  4. Compare your query with the accepted one and read the Common Mistakes section.

Author

Arpan Chakraborty GitHub: ArpanC6

If this repository helped you, a star is appreciated.

About

A complete guide to LeetCode SQL 50 with handwritten notes, visual explanations, and optimal solutions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors