Skip to content

1795. Rearrange Products Table 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
SELECT
  product_id,
  'store1' AS store,
  store1 AS price
FROM Products
WHERE store1 IS NOT NULL
UNION ALL
SELECT
  product_id,
  'store2',
  store2
FROM Products
WHERE store2 IS NOT NULL
UNION ALL
SELECT
  product_id,
  'store3',
  store3
FROM Products
WHERE store3 IS NOT NULL;