表1的格式如下:
UT | temp_m1 | temp_m2 | temp_m3 | temp_m4 | air_m1 | air_m2 | air_m3 | air_m4 |
我想用以下格式制作表2:
UT | location | temp | air
表1的每行有4行。
实现这一目标的简单方法是:
create table2 as
Select ut,'m1' as location, temp_m1 as temp, air_m1 as air
from table1
union all
Select ut,'m2' as location, temp_m2 as temp, air_m2 as air
from table1
union all
Select ut,'m3' as location, temp_m3 as temp, air_m3 as air
from table1
union all
Select ut,'m4' as location, temp_m4 as temp, air_m4 as air
from table1;
但看看任务管理器,似乎我们必须阅读同一个表4次,然后加入结果。
读一次,然后在“瞄准”处分开应该更容易,但我找不到办法。
暂无答案!
目前还没有任何答案,快来回答吧!