> For the complete documentation index, see [llms.txt](https://dailyjournal.gitbook.io/solutions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dailyjournal.gitbook.io/solutions/leetcode-solutions/problems/database/easy/1795-rearrange-products-table.md).

# #1795 Rearrange Products Table

#### <https://leetcode.com/problems/rearrange-products-table/>

{% tabs %}
{% tab title="Second Tab" %}

```sql
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
```

{% endtab %}
{% endtabs %}
