Skip to content

Commit d5aaa0b

Browse files
committed
Upload 169
1 parent d5cf278 commit d5aaa0b

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ Because this project necessitated a framework to enable consistent daily practic
202202
| 166 | [Films selection with a twist](https://www.codewars.com/kata/644424f8d7bab510f1375d20) | [Solution](solutions/166_films_selection_with_a_twist.md) | Codewars | Medium | `PERCENTILE_DISC` |
203203
| 167 | [SQL Basics: Raise to the Power](https://www.codewars.com/kata/594a8f653b5b4e8f3d000035) | [Solution](solutions/167_sql_basics_raise_to_the_power.md) | Codewars | Easy | `^` or `POW()` |
204204
| 168 | [SQL Basics: Simple UNION ALL](https://www.codewars.com/kata/58112f8004adbbdb500004fe/sql) | [Solution](solutions/168_sql_basics_simple_union_all.md) | Codewars | Medium | |
205+
| 169 | [NPV Queries](https://leetcode.com/problems/npv-queries/description/) | [Solution](solutions/169_npv_queries.md) | LeetCode | Easy | |
205206
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
206207
<!--- cSpell:enable --->
207208

solutions/169_npv_queries.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SQL Everyday \#169
2+
3+
## NPV Queries
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Easy
7+
8+
## Problem
9+
10+
Write a solution to find the `npv` of each query of the `Queries` table.
11+
12+
Return the result table in *any order*. [[Full Description](https://leetcode.com/problems/npv-queries/description/)]
13+
14+
## Submitted Solution
15+
16+
```sql
17+
-- Submitted Solution
18+
SELECT
19+
q.id
20+
,q.year
21+
,COALESCE(n.npv, 0) AS npv
22+
FROM Queries AS q
23+
LEFT JOIN NPV AS n ON q.id = n.id
24+
AND q.year = n.year
25+
;
26+
```
27+
28+
## Site Solution
29+
30+
```sql
31+
-- LeetCode Solution
32+
SELECT
33+
Q.id,
34+
Q.year,
35+
IFNULL(N.npv, 0) AS npv
36+
FROM
37+
Queries Q
38+
LEFT JOIN NPV N ON Q.id = N.id
39+
AND Q.year = N.year;
40+
```
41+
42+
## Notes
43+
44+
TBD
45+
46+
## NB
47+
48+
TBD
49+
50+
Go to [Index](../?tab=readme-ov-file#index)\
51+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)