siqichen-usc/LeetCode-SQL-Summary
Tentang
*Summary of 102 LeetCode SQL questions* This note aims to help people learn and review SQL efficiently. The first draft mainly focuses on T-SQL/MS SQL Server.
Data dan analisisPertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- +1
- dalam 15 hari
- +1
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliLeetCode SQL Summary
Last updated on August 8, 2021, covered 106 LeetCode SQL questions
WIP
- Update new SQL questions (Estimated Time: 31 August, 2021)
- Rearrange the repository (Estimated Time: 25 September, 2021 - My Brithday :D)
- Only one solution folder will be kept
- Update solution link
- Add Column "Topic" for LeetCode SQL Questions by ID
Intro
After finishing all 102 LeetCode SQL questions, I feel it could be good to summarize all questions by topics.
This note aims to help people learn and review SQL effeciently, espeically when trying to have a quick catch up on a certain topic, e.g. complex join, window function, recursive CTE and etc. If you would like to try questions by ID, you could jump to LeetCode SQL Questions by ID where I list all questions coverred in this repository.
And for the first draft, I mainly focus on T-SQL/MS SQL Server.
Table of Content
LeetCode SQL Questions by Topics
Basics
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 182 | Duplicate Emails | Easy | Soln. |
| 511 | Game Play Analysis I | Easy | Soln. |
| 578 | Get Highest Answer Rate Question | Medium | Soln. |
| 584 | Find Customer Referee | Easy | Soln. |
| 586 | Customer Placing the Largest Number of Orders | Easy | Soln. |
| 595 | Big Countries | Easy | Soln. |
| 596 | Classes More Than 5 Students | Easy | Soln. |
| 619 | Biggest Single Number | Easy | Soln. |
| 620 | Not Boring Movies | Easy | Soln. |
| 1050 | Actors and Directors Who Cooperated At Least Three Times | Easy | Soln. |
| 1069 | Product Sales Analysis II | Easy | Soln. |
| 1076 | Project Employees II | Easy | Soln. |
| 1082 | Sales Analysis I | Easy | Soln. |
| 1141 | User Activity for the Past 30 Days I | Easy | Soln. |
| 1148 | Article Views I | Easy | Soln. |
| 1149 | Article Views II | Medium | Soln. |
SQL Command
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 196 | Delete Duplicate Emails | Easy | Soln. |
| 627 | Swap Salary | Easy | Soln. |
Join
- Simple Join
- Advanced Join
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 180 | Consecutive Numbers | Medium | Soln. |
| 196 | Delete Duplicate Emails | Easy | Soln. |
| 534 | Game Play Analysis III | Medium | Soln. |
| 569 | Median Employee Salary | Hard | Soln. |
| 579 | Find Cumulative Salary of an Employee | Hard | Soln. |
| 601 | Human Traffic of Stadium | Hard | Soln. |
| 603 | Consecutive Available Seats | Easy | Soln. |
| 612 | Shortest Distance in a Plane | Medium | Soln. |
| 613 | Shortest Distance in a Line | Easy | Soln. |
| 1097 | Game Play Analysis V | Hard | Soln. |
| 1126 | Active Businesses | Medium | Soln. |
| 1127 | User Purchase Platform | Hard | Soln. |
| 1159 | Market Analysis II | Medium | Soln. |
| 1194 | Tournament Winners | Hard | Soln. |
| 1212 | Team Scores in Football Tournament | Medium | Soln. |
| 1225 | Report Contiguous Dates | Hard | Soln. |
| 1251 | Average Selling Price | Easy | Soln. |
| 1285 | Find the Start and End Number of Continuous Ranges | Medium | Soln. |
| 1308 | Running Total for Different Genders | Medium | Soln. |
| 1321 | Restaurant Growth | Medium | Soln. |
| 1369 | Get the Second Most Recent Activity | Hard | Soln. |
Subquery
- Simple Subquery
- Advanced Subquery
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 262 | Trips and Users | Hard | Soln. |
| 550 | Game Play Analysis IV | Medium | Soln. |
| 569 | Median Employee Salary | Hard | Soln. |
| 585 | Investments in 2016 | Medium | Soln. |
| 597 | Friend Requests I: Overall Acceptance Rate | Easy | Soln. |
| 601 | Human Traffic of Stadium | Hard | Soln. |
| 1077 | Project Employees II | Medium | Soln. |
| 1127 | User Purchase Platform | Hard | Soln. |
| 1159 | Market Analysis II | Medium | Soln. |
| 1164 | Product Price at a Given Date | Medium | Soln. |
| 1194 | Tournament Winners | Hard | Soln. |
| 1205 | Monthly Transactions II | Medium | Soln. |
| 1270 | All People Report to the Given Manager | Medium | Soln. |
| 1398 | Customers Who Bought Products A and B but Not C | Medium | Soln. |
- Recursive CTE
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 1270 | All People Report to the Given Manager | Medium | Soln. |
| 1336 | Number of Transactions per Visit | Hard | Soln. |
| 1384 | Total Sales Amount by Year | Hard | Soln. |
Window Function
CASE WHEN or IIF
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 262 | Trips and Users | Hard | Soln. |
| 597 | Friend Requests I: Overall Acceptance Rate | Easy | Soln. |
| 608 | Tree Node | Medium | Soln. |
| 610 | Triangle Judgement | Easy | Soln. |
| 615 | Average Salary: Departments VS Company | Hard | Soln. |
| 618 | Students Report By Geography | Hard | Soln. |
| 626 | Exchange Seats | Medium | Soln. |
| 627 | Swap Salary | Easy | Soln. |
| 1126 | Active Businesses | Medium | Soln. |
| 1142 | User Activity for the Past 30 Days II | Easy | Soln. |
| 1158 | Market Analysis I | Medium | Soln. |
| 1159 | Market Analysis II | Medium | Soln. |
| 1173 | Immediate Food Delivery I | Easy | Soln. |
| 1174 | Immediate Food Delivery II | Medium | Soln. |
| 1193 | Monthly Transactions I | Medium | Soln. |
| 1194 | Tournament Winners | Hard | Soln. |
| 1211 | Queries Quality and Percentage | Easy | Soln. |
| 1212 | Team Scores in Football Tournament | Medium | Soln. |
| 1264 | Page Recommendations | Medium | Soln. |
| 1294 | Weather Type in Each Country | Easy | Soln. |
| 1322 | Ads Performance | Easy | Soln. |
| 1393 | Capital Gain/Loss | Medium | Soln. |
| 1398 | Customers Who Bought Products A and B but Not C | Medium | Soln. |
OFFSET FETCH
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 176 | Second Highest Salary | Easy | Soln. |
| 177 | Nth Highest Salary | Medium | Soln. |
| 1321 | Restaurant Growth | Medium | Soln. |
PIVOT and UNPIVOT
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 602 | Friend Requests II: Who Has the Most Friends | Medium | Soln. |
| 618 | Students Report By Geography | Hard | Soln. |
| 1179 | Reformat Department Table | Easy | Soln. |
| 1322 | Ads Performance | Easy | Soln. |
Variable
| # | Title | Difficulty | Solution |
|---|---|---|---|
| 597 | Friend Requests I: Overall Acceptance Rate | Easy | Soln. |
| 1098 | Unpopular Books | Medium | Soln. |
| 1107 | New Users Daily Count | Medium | Soln. |
| 1113 | Reported Posts | Easy | Soln. |
LeetCode SQL Questions by ID
Jelajahi proyek terkait
Memuat…