Skip to content

Commit f317289

Browse files
committed
Upload 157
1 parent d20aa70 commit f317289

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-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/), or simply `eevveerryyddaayy`. For more info, including instructions on installation, configuration and usage, go to [here](https://github.com/ggeerraarrdd/eevveerryyddaayy).
13+
> `SQL Everyday` has been templatized into [`eevveerryyddaayy`](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

@@ -185,6 +185,7 @@ Because this project necessitated a framework to enable consistent daily practic
185185
| 154 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails/description/) | [Solution](solutions/154_find_users_with_valid_e_mails.md) | LeetCode | Easy | Regex |
186186
| 155 | [Actors and Directors Who Cooperated At Least Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/description/) | [Solution](solutions/155_actors_and_directors_who_cooperated_at_least_three_times.md) | LeetCode | Easy | |
187187
| 156 | [Top Travellers](https://leetcode.com/problems/top-travellers/description/) | [Solution](solutions/156_top_travellers.md) | LeetCode | Easy | |
188+
| 157 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table/description/) | [Solution](solutions/157_rearrange_products_table.md) | LeetCode | Easy | |
188189
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
189190
<!--- cSpell:enable --->
190191

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SQL Everyday \#157
2+
3+
## Rearrange Products Table
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Easy
7+
8+
## Problem
9+
10+
Write a solution to rearrange the `Products` table so that each row has `(product_id, store, price)`. If a product is not available in a store, do not include a row with that `product_id` and `store` combination in the result table.
11+
12+
Return the result table in *any order*. [[Full Description](https://leetcode.com/problems/rearrange-products-table/description/)]
13+
14+
## Submitted Solution
15+
16+
```sql
17+
-- Submitted Solution
18+
-- Write your PostgreSQL query statement below
19+
SELECT
20+
product_id
21+
,'store1' AS store
22+
,store1 AS price
23+
FROM Products
24+
WHERE store1 IS NOT NULL
25+
UNION ALL
26+
SELECT
27+
product_id
28+
,'store2' AS store
29+
,store2 AS price
30+
FROM Products
31+
WHERE store2 IS NOT NULL
32+
UNION ALL
33+
SELECT
34+
product_id
35+
,'store3' AS store
36+
,store3 AS price
37+
FROM Products
38+
WHERE store3 IS NOT NULL
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+
TBD
56+
57+
Go to [Index](../?tab=readme-ov-file#index)\
58+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)