10000 Update README.md · ThejaRoop/sql-50-leetcode@91afb6b · GitHub
[go: up one dir, main page]

Skip to content

Commit 91afb6b

Browse files
committed
Update README.md
1 parent d631a6a commit 91af
10000
b6b

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

README.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ Solutions for [SQL 50 Study Plan](https://leetcode.com/studyplan/top-sql-50/) on
33

44
---
55

6-
1757 - Recyclable and Low Fat Products
6+
[1757 - Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products/)
77
```sql
88
SELECT product_id
99
FROM Products
1010
WHERE low_fats = 'Y'
1111
AND recyclable = 'Y'
1212
```
1313

14-
584 - Find Customer Referee
14+
[584 - Find Customer Referee](https://leetcode.com/problems/find-customer-referee)
1515
```sql
1616
SELECT name
1717
FROM Customer
1818
WHERE referee_id != 2 OR referee_id IS null
1919
```
2020

21-
595 - Big Countries
21+
[595 - Big Countries](https://leetcode.com/problems/big-countries/)
2222
```sql
2323
SELECT name, population, area
2424
FROM WORLD
2525
WHERE area >= 3000000
2626
OR population >= 25000000
2727
```
2828

29-
1148 - Article Views I
29+
[1148 - Article Views I](https://leetcode.com/problems/article-views-i)
3030
```sql
3131
SELECT DISTINCT author_id as id
3232
FROM Views
@@ -35,39 +35,38 @@ AND author_id = viewer_id
3535
ORDER BY author_id
3636
```
3737

38-
1683 - Invalid Tweets
38+
[1683 - Invalid Tweets](https://leetcode.com/problems/invalid-tweets/)
3939
```sql
4040
SELECT tweet_id
4141
FROM Tweets
4242
WHERE length(content) > 15
4343
```
4444

45-
1378 - Replace Employee ID With The Unique
46-
Identifier
45+
[1378 - Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier)
4746
```sql
4847
SELECT unique_id, name
4948
FROM Employees e
5049
LEFT JOIN EmployeeUNI eu
5150
ON e.id = eu.id
5251
```
5352

54-
1068 - Product Sales Analysis I
53+
[1068 - Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i/)
5554
```sql
5655
SELECT product_name, year, price
5756
FROM Sales s
5857
LEFT JOIN Product p
5958
ON s.product_id = p.product_id
6059
```
6160

62-
1581 - Customer Who Visited but Did Not Make Any Transactions
61+
[1581 - Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions/)
6362
```sql
6463
SELECT customer_id, COUNT(*) as count_no_trans
6564
FROM Visits
6665
WHERE visit_id NOT IN (SELECT DISTINCT visit_id FROM Transactions)
6766
GROUP BY customer_id
6867
```
6968

70-
197. Rising Temperature
69+
[197 - Rising Temperature](https://leetcode.com/problems/rising-temperature/)
7170
```sql
7271
SELECT w1.id
7372
FROM Weather w1, Weather w2
@@ -81,7 +80,7 @@ WHERE w1.temperature > w2.temperature
8180
AND SUBDATE(w1.recordDate, 1) = w2.recordDate
8281
```
8382

84-
1661. Average Time of Process per Machine
83+
[1661 - Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine/)
8584
```sql
8685
SELECT machine_id, ROUND(AVG(end - start), 3) AS processing_time
8786
FROM
@@ -93,7 +92,7 @@ FROM
9392
GROUP BY machine_id
9493
```
9594

96-
577. Employee Bonus
95+
[577 - Employee Bonus](https://leetcode.com/problems/employee-bonus/solutions/)
9796
```sql
9897
SELECT name, bonus
9998
FROM Employee e
@@ -103,7 +102,7 @@ WHERE bonus < 1000
103102
OR bonus IS NULL
104103
```
105104

106-
1280. Students and Examinations
105+
[1280 - Students and Examinations](https://leetcode.com/problems/students-and-examinations/)
107106
```sql
108107
SELECT a.student_id, a.student_name, b.subject_name, COUNT(c.subject_name) AS attended_exams
109108
FROM Students a
@@ -113,4 +112,23 @@ ON a.student_id = c.student_id
113112
AND b.subject_name = c.subject_name
114113
GROUP BY 1, 3
115114
ORDER BY 1, 3
115+
```
116+
[570. Managers with at Least 5 Direct Reports](https://leetcode.com/problems/managers-with-at-least-5-direct-reports)
117+
```sql
118+
SELECT name
119+
FROM Employee
120+
WHERE id IN
121+
(SELECT managerId
122+
FROM Employee
123+
GROUP BY managerId
124+
HAVING COUNT(*) >= 5
125+
)
126+
127+
-- OR
128+
SELECT a.name
129+
FROM Employee a
130+
JOIN Employee b
131+
WHERE a.id = b.managerId
132+
GROUP BY b.managerId
133+
HAVING COUNT(*) >= 5
116134
```

0 commit comments

Comments
 (0)
0