Skip to content

Commit fd12e31

Browse files
committed
Section 02 : Basic Join : part 02
1 parent e793259 commit fd12e31

4 files changed

+29
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT e.name, b.bonus
2+
FROM Employee e
3+
LEFT JOIN Bonus b ON e.empId = b.empId
4+
WHERE b.bonus < 1000 OR b.bonus IS NULL;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SELECT s.student_id, s.student_name, sub.subject_name, COUNT(e.student_id) AS attended_exams
2+
FROM Students AS s
3+
INNER JOIN Subjects AS sub
4+
LEFT JOIN Examinations as e
5+
ON (s.student_id = e.student_id AND sub.subject_name = e.subject_name)
6+
GROUP BY s.student_id, sub.subject_name
7+
ORDER BY student_id, subject_name
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SELECT name
2+
FROM Employee
3+
WHERE id
4+
IN
5+
(
6+
SELECT managerId
7+
FROM Employee
8+
GROUP BY managerId
9+
HAVING count(*)>=5
10+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT
2+
s.user_id,
3+
IFNULL(ROUND(SUM(CASE WHEN c.action = 'confirmed' THEN 1 ELSE 0 END) / COUNT(c.user_id), 2), 0) AS confirmation_rate
4+
FROM
5+
Signups s
6+
LEFT JOIN Confirmations c ON s.user_id = c.user_id
7+
GROUP BY
8+
s.user_id;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy