Skip to content

Commit 99fbeed

Browse files
authored
Create investments-in-2016.sql
1 parent 41f4083 commit 99fbeed

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

MySQL/investments-in-2016.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Time: O(n^2)
2+
# Space: O(n)
3+
4+
SELECT
5+
SUM(insurance.TIV_2016) AS TIV_2016
6+
FROM
7+
insurance
8+
WHERE
9+
insurance.TIV_2015 IN
10+
(
11+
SELECT
12+
TIV_2015
13+
FROM
14+
insurance
15+
GROUP BY TIV_2015
16+
HAVING COUNT(*) > 1
17+
ORDER BY NULL
18+
)
19+
AND CONCAT(LAT, LON) IN
20+
(
21+
SELECT
22+
CONCAT(LAT, LON)
23+
FROM
24+
insurance
25+
GROUP BY LAT , LON
26+
HAVING COUNT(*) = 1
27+
ORDER BY NULL
28+
)
29+
;

0 commit comments

Comments
 (0)