I currently have a table that looks like this:
date ---- x ---- y ---- z
2020----- 2 ---- 4 ---- 8
2018 ---- 3 ---- 3 ---- 2
2019 ---- 1 ---- 6 ---- 0
I like to rotate this table meaning that the columns become rows like this:
date ---- metric ---- value
2020 ---- x ---- 2
2018 ---- x ---- 3
2019 ---- x ---- 1
2020 ---- y ---- 4
2018 ---- y ---- 3
2019 ---- y ---- 6
2020 ---- z ---- 8
2018 ---- z ---- 2
2019 ---- z ---- 0
If it was in python, I could do it using the pivote() or t() function. However, I am not sure how to do it with SQL. Could you please help me with that?
Thanks!