I am very new to SQL with presto and trying to unpivot a table that looks like this: Pivot to make it look like this: Unpivoted
I have tried using UNPIVOT function, I have tried CROSS JOINING with unnest. I finally thought I had figured it out using UNION but I can quiet get the query right. Could you please push me in the right direction?
This is what I was working on:
SELECT CASE_ID, Account, Amount
FROM
TEST_TABLE
CROSS JOIN UNNEST (
ARRAY['Factor_Cost','Unfactor_cost'],
ARRAY[Factor_Cost,Unfactor_cost]
) t2(account, amount)
Thanks so much, R