8000 Update README.md · Atharv625/sql-50-leetcode@d631a6a · GitHub
[go: up one dir, main page]

Skip to content

Commit d631a6a

Browse files
committed
Update README.md
1 parent 57d4ae0 commit d631a6a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,50 @@ WHERE visit_id NOT IN (SELECT DISTINCT visit_id FROM Transactions)
6767
GROUP BY customer_id
6868
```
6969

70+
197. Rising Temperature
71+
```sql
72+
SELECT w1.id
73+
FROM Weather w1, Weather w2
74+
WHERE DATEDIFF(w1.recordDate, w2.recordDate) = 1
75+
AND w1.temperature > w2.temperature
76+
77+
-- OR
78+
SELECT w1.id
79+
FROM Weather w1, Weather w2
80+
WHERE w1.temperature > w2.temperature
81+
AND SUBDATE(w1.recordDate, 1) = w2.recordDate
82+
```
7083

84+
1661. Average Time of Process per Machine
85+
```sql
86+
SELECT machine_id, ROUND(AVG(end - start), 3) AS processing_time
87+
FROM
88+
(SELECT machine_id, process_id,
89+
MAX(CASE WHEN activity_type = 'start' THEN timestamp END) AS start,
90+
MAX(CASE WHEN activity_type = 'end' THEN timestamp END) AS end
91+
FROM Activity
92+
GROUP BY machine_id, process_id) AS subq
93+
GROUP BY machine_id
94+
```
7195

96+
577. Employee Bonus
97+
```sql
98+
SELECT name, bonus
99+
FROM Employee e
100+
LEFT JOIN Bonus b
101+
ON e.empId = b.empId
102+
WHERE bonus < 1000
103+
OR bonus IS NULL
104+
```
72105

106+
1280. Students and Examinations
107+
```sql
108+
SELECT a.student_id, a.student_name, b.subject_name, COUNT(c.subject_name) AS attended_exams
109+
FROM Students a
110+
JOIN Subjects b
111+
LEFT JOIN Examinations c
112+
ON a.student_id = c.student_id
113+
AND b.subject_name = c.subject_name
114+
GROUP BY 1, 3
115+
ORDER BY 1, 3
116+
```

0 commit comments

Comments
 (0)
0