'Unpivot/Transpose in Presto SQL

enter image description here

I have a dynamic table in the format shown in the image (left hand side). A new month column will be added every month. How do I unpivot month in Presto? I can do it with this code below but I'll have to write it every month when there is a new column. Is there any better way?

Select 
    KPI, KPI_Owner,month,
    t2.Value
From Table T1
CROSS JOIN unnest (
    array['2021_jan','2021_feb','2021_mar'],
    array["2021_jan", "2021_feb", "2021_mar"]
) t2(month,value)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source