In Redshift :
I've a table with 30 dimension fields and more than 150 measure fields.
To make good use of these data in a visualization tool (Tableau), I need to Unpivot the measure columns into only one measure and one dimension to categorize them.
Short Example:
Date Country Order Banana Apple Orange Kiwi Lemon
1-10-2018 Belgium XYZ789 14 0 10 16 7
1-10-2018 Germany ABC123 10 15 3 15 3
2-10-2018 Belgium KLM456 9 9 7 1 7
Result :
Date Country Order Measure_Name Measure_Value
1-10-2018 Belgium XYZ789 Banana 14
1-10-2018 Belgium XYZ789 Apple 0
1-10-2018 Belgium XYZ789 Orange 10
1-10-2018 Belgium XYZ789 Kiwi 16
1-10-2018 Belgium XYZ789 Lemon 7
1-10-2018 Germany ABC123 Banana 10
1-10-2018 Germany ABC123 Apple 15
1-10-2018 Germany ABC123 Orange 3
1-10-2018 Germany ABC123 Kiwi 15
1-10-2018 Germany ABC123 Lemon 3
2-10-2018 Belgium KLM456 Banana 9
2-10-2018 Belgium KLM456 Apple 9
2-10-2018 Belgium KLM456 Orange 7
2-10-2018 Belgium KLM456 Kiwi 1
2-10-2018 Belgium KLM456 Lemon 7
I know and I've tried the 'UNION ALL' solution but my table count millions of rows, and more than 150 columns to unpivot is really too huge for this solution. (Even The SQL is more than 8k rows long)
Do you have any Idea to help me ?
Thanks a lot,