LeetCode SQL 50 Questions Challenge
LeetCode SQL 50 Questions Challenge
SQL 50
Challenge
LEETCODE
*Disclaimer*
Everyone learns uniquely.
www.bosscoderacademy.com 1
Select
Problem 01
Recyclable and Low Fat Products
Write a solution to find the ids of products that are both low
fat and recyclable. Return the result table in any order. The
result format is in the following example.
www.bosscoderacademy.com 2
Problem 02
Find Customer Referee
Find the names of the customers that are not referred by the
customer with id = 2. Return the result table in any order.
The result format is in the following example.
www.bosscoderacademy.com 3
Problem 03
Big Countries
www.bosscoderacademy.com 4
Problem 04
Article Views I
Write a solution to find all the authors who viewed at least one
of their own articles. Return the result table sorted by id in
ascending order. The result format is in the following example.
www.bosscoderacademy.com 5
Problem 05
Invalid Tweets
Write a solution to find the IDs of the invalid tweets. The tweet
is invalid if the number of characters used in the content of
the tweet is strictly greater than 15.
www.bosscoderacademy.com 6
Basic Joins
Problem 06
Replace Employee ID With The
Unique Identifier
www.bosscoderacademy.com 7
Problem 07
Product Sales Analysis I
www.bosscoderacademy.com 8
Problem 08
Customer Who Visited but Did Not
Make Any Transactions
www.bosscoderacademy.com 9
Problem 09
Rising Temperature
www.bosscoderacademy.com 10
Problem 10
Average Time of Process per
Machine
www.bosscoderacademy.com 11
The resulting table should have the machine_id along with the
average time as processing_time, which should be rounded to
3 decimal places.
www.bosscoderacademy.com 12
Problem 11
Employee Bonus
www.bosscoderacademy.com 13
Problem 12
Student and Examinations
www.bosscoderacademy.com 14
Problem 13
Managers with at Least 5 Direct
Reports
www.bosscoderacademy.com 15
Problem 14
Confirmation Rate
www.bosscoderacademy.com 16
Basic Aggregate Functions
Problem 15
Not Boring Movies
www.bosscoderacademy.com 17
Problem 16
Confirmation Rate
www.bosscoderacademy.com 18
Problem 17
Project Employees I
www.bosscoderacademy.com 19
Problem 18
Average Selling Price
www.bosscoderacademy.com 20
Problem 19
Percentage of Users Attended a
Contest
www.bosscoderacademy.com 21
Problem 20
Queries Quality and Percentage
The average of the ratio between query rating and its position.
www.bosscoderacademy.com 22
Problem 21
Monthly Transaction I
Write an SQL query to find for each month and country, the
number of transactions and their total amount, the number of
approved transactions and their total amount.
www.bosscoderacademy.com 23
Problem 22
Immediate Food Delivery II
The first order of a customer is the order with the earliest order date
that the customer made. It is guaranteed that a customer has
precisely one first order.
www.bosscoderacademy.com 24
Problem 23
Game Play Analysis IV
www.bosscoderacademy.com 25
Sorting and Grouping
Problem 24
Number of Unique Subjects Taught
by Each Teacher
www.bosscoderacademy.com 26
Problem 25
User Activity for the Past 30 Days I
Write a solution to find the daily active user count for a period of
30 days ending 2019-07-27 inclusively. A user was active on
someday if they made at least one activity on that day.
www.bosscoderacademy.com 27
Problem 26
Product Sales Analysis III
www.bosscoderacademy.com 28
Problem 27
Classes More Than 5 Students
www.bosscoderacademy.com 29
Problem 28
Find Followers Count
www.bosscoderacademy.com 30
Problem 29
Biggest Single Number
www.bosscoderacademy.com 31
Problem 30
Customers Who Bought All Products
www.bosscoderacademy.com 32
Problem 31
Customers Who Bought All Products
The result table must contain all three categories. If there are no
accounts in a category, return 0.
www.bosscoderacademy.com 33
Advanced Select and Joins
Problem 32
The Number of Employees Which
Report to Each Employee
Practice Here ->
Problem 33
Primary Department for Each
Employee
Practice Here ->
Problem 34
Triangle Judgement
Practice Here ->
www.bosscoderacademy.com 34
Problem 35
Consecutive Numbers
Practice Here ->
Problem 36
Product Price at a Given Date
Practice Here ->
Problem 37
Last Person to Fit in the Bus
Practice Here ->
Problem 38
Count Salary Categories
Practice Here ->
www.bosscoderacademy.com 35
Subqueries
Problem 39
Employees Whose Manager Left the
Company
Practice Here ->
Problem 40
Exchange Seats
Practice Here ->
Problem 41
Movie Rating
Practice Here ->
www.bosscoderacademy.com 36
Problem 42
Restaurant Growth
Practice Here ->
Problem 43
Friend Requests II: Who Has the
Most Friends
Practice Here ->
Problem 44
Investments in 2016
Practice Here ->
Problem 45
Department Top Three Salaries
Practice Here ->
www.bosscoderacademy.com 37
Advanced String
Functions / Regex / Clause
Problem 46
Fix Names in a Table
Practice Here ->
Problem 47
Patients With a Condition
Practice Here ->
Problem 48
Delete Duplicate Emails
Practice Here ->
www.bosscoderacademy.com 38
Problem 49
Second Highest Salary
Practice Here ->
Problem 50
Group Sold Products By The Date
Practice Here ->
www.bosscoderacademy.com 39
Why
Bosscoder?
2200+ Alumni placed at Top
Product-based companies.
Explore More