Leetcode Note: MySQL - Rearrange Products Table
Rearrange Products Table - LeetCode
https://leetcode.com/problems/rearrange-products-table/
- MySQL で取り組んだメモ
回答
✅MySQL || Beginner level ||Easy to Understand||Simple-Short -Solution✅ - Rearrange Products Table - LeetCode
https://leetcode.com/problems/rearrange-products-table/solutions/2521016/mysql-beginner-level-easy-to-understand-simple-short-solution/
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