Skip to content

Commit dbb2005

Browse files
committed
Upload 135
1 parent cdfb55a commit dbb2005

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ One SQL problem a day for a year
1010
1111
<!-- markdownlint-enable MD028 -->
1212
> [!NOTE]
13-
> `SQL Everyday` has been templatized into [`eevveerryyddaayy-template`](https://github.com/ggeerraarrdd/eevveerryyddaayy-template/). For more info, including instructions on installation, configruation and usage, go to [`eevveerryyddaayy`](https://github.com/ggeerraarrdd/eevveerryyddaayy).
13+
> `SQL Everyday` has been templatized into [`eevveerryyddaayy-template`](https://github.com/ggeerraarrdd/eevveerryyddaayy-template/), or simply `eevveerryyddaayy`. For more info, including instructions on installation, configruation and usage, go to [here](https://github.com/ggeerraarrdd/eevveerryyddaayy).
1414
1515
_SQL Everyday_ is a personal challenge to solve at least one SQL problem everyday for the next 365 days, starting from September 28, 2024.
1616

@@ -167,6 +167,7 @@ The problems and both submitted and site solutions are documented in individual
167167
| 132 | [Movie Rating](https://leetcode.com/problems/movie-rating/description/) | [Solution](solutions/132_movie_rating.md) | LeetCode | Medium | |
168168
| 133 | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth/description/) | [Solution](solutions/133_restaurant_growth.md) | LeetCode | Medium | |
169169
| 134 | [Friend Requests II: Who Has the Most Friends](https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends/description/) | [Solution](solutions/134_friend_requests_ii_who_has_the_most_friends.md) | LeetCode | Medium | `UNION ALL` |
170+
| 135 | [Investments in 2016](https://leetcode.com/problems/investments-in-2016/description/) | [Solution](solutions/135_investments_in_2016.md) | LeetCode | Medium | |
170171
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
171172

172173
## Author(s)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SQL Everyday \#135
2+
3+
## Investments in 2016
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Medium
7+
8+
## Problem
9+
10+
Write a solution to report the sum of all total investment values in 2016 `tiv_2016`, for all policyholders who:
11+
12+
* have the same `tiv_2015` value as one or more other policyholders, and
13+
* are not located in the same city as any other policyholder (i.e., the (`lat`, `lon`) attribute pairs must be unique).
14+
15+
Round `tiv_2016` to two decimal places. [[Full Description](https://leetcode.com/problems/investments-in-2016/description/)]
16+
17+
## Submitted Solution
18+
19+
```sql
20+
-- Submitted Solution
21+
SELECT
22+
ROUND(SUM(tiv_2016), 2) AS tiv_2016
23+
FROM Insurance
24+
WHERE tiv_2015 IN (
25+
SELECT
26+
tiv_2015
27+
FROM Insurance
28+
GROUP BY tiv_2015
29+
HAVING COUNT(*) > 1
30+
)
31+
AND (lat, lon) IN (
32+
SELECT
33+
lat
34+
,lon
35+
FROM Insurance
36+
GROUP BY lat, lon
37+
HAVING COUNT(*) = 1
38+
)
39+
;
40+
```
41+
42+
## Site Solution
43+
44+
```sql
45+
-- LeetCode Solution
46+
-- TBD
47+
```
48+
49+
## Notes
50+
51+
TBD
52+
53+
## NB
54+
55+
56+
57+
Go to [Index](../?tab=readme-ov-file#index)\
58+
Go to [Overview](../?tab=readme-ov-file)
59+

0 commit comments

Comments
 (0)