-
1795. Rearrange Products Table mysqlLeetCode_Study_Plan/SQL 2022. 9. 29. 18:09
https://leetcode.com/problems/rearrange-products-table
select p1.product_id, 'store1' as store, store1 as price from (SELECT product_id, store1 FROM Products) p1 where store1 is not null union select p2.product_id, 'store2' as store, store2 as price from (SELECT product_id, store2 FROM Products) p2 where store2 is not null union select p3.product_id, 'store3' as store, store3 as price from (SELECT product_id, store3 FROM Products) p3 where store3 is not null
매우 구린방법으로 푼 것 같다.. 아마도 원시적인 풀이가 되기도 하면서도 조회속도도 느릴 것으로 추정
'LeetCode_Study_Plan > SQL' 카테고리의 다른 글
1581. Customer Who Visited but Did Not Make Any Transactions mysql (0) 2022.09.30 175. Combine Two Tables mysql (0) 2022.09.30 1965. Employees With Missing Information mysql (0) 2022.09.29 1527. Patients With a Condition mysql (0) 2022.09.27 1484. Group Sold Products By The Date mysql (0) 2022.09.27