-1

I am have a table like below

Company jan_value feb_value

sony 10 20

I wan to get a result like below

company value1 value2

sony jan_value 10

sony feb_value 20

I was trying to us unpivot but my sql does not support unpivot option since it is google sql. i really need help on this. thank you in advance

Soni Sol
  • 2,367
  • 3
  • 12
  • 23

1 Answers1

1

In SQL in general, you can use union all:

select company, 'jan_value' as value1, jan_value as value2
from t
union all
select company, 'feb_value' as value1, feb_value as value2
from t;

There may be more efficient methods depending on your database. GCP supports multiple databases.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786