Skip to content

Commit 0b20bd9

Browse files
committed
Section 06 : Subqueries - part 03 - P 5 , 6
1 parent e6653a4 commit 0b20bd9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
SELECT requester_id AS id,
2+
( SELECT COUNT(*)
3+
FROM RequestAccepted
4+
WHERE requester_id = id OR accepter_id = id
5+
) AS num
6+
7+
FROM RequestAccepted
8+
GROUP BY requester_id
9+
10+
UNION
11+
12+
SELECT accepter_id as id,
13+
( SELECT COUNT(*)
14+
FROM RequestAccepted
15+
WHERE requester_id = id OR accepter_id = id
16+
) AS num
17+
FROM RequestAccepted
18+
GROUP BY accepter_id
19+
20+
ORDER BY num DESC LIMIT 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SELECT ROUND(SUM(insurance.TIV_2016),2) AS TIV_2016
2+
FROM insurance
3+
WHERE insurance.TIV_2015 IN
4+
(
5+
SELECT TIV_2015
6+
FROM insurance
7+
GROUP BY TIV_2015
8+
HAVING COUNT(*) > 1
9+
)
10+
AND CONCAT(LAT, LON) IN
11+
(
12+
SELECT CONCAT(LAT, LON)
13+
FROM insurance
14+
GROUP BY LAT , LON
15+
HAVING COUNT(*) = 1
16+
)

0 commit comments

Comments
 (0)