Problem Solving

[LeetCode] Rearrange Products Table

luminous13 2022. 11. 8. 13:08

문제

풀이

select구에 문자열을 입력해서 속성 값을 설정할 수 있는 것이 포인트였던 문제.

1
2
3
4
5
6
7
8
9
10
11
12
13
select product_id, 'store1' as store, store1 as price
from products
where store1 is not null
union
select product_id, 'store2' as store, store2 as price
from products
where store2 is not null
union
select product_id, 'store3' as store, store3 as price
from products
where store3 is not null;
 
 
cs