sql 列转行
将一条查询结果,本开始横向的一条记录,想让他显示为一列,此处查询了130项因子数据,sql语句看着吓人,只看一两行就ok
转换结果
sql语句:
select b.c1 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c2 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c3 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c4 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c5 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c6 as climate_value from climate_index b where tm='195101' UNION ALL
......
......
select b.c125 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c126 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c127 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c128 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c129 as climate_value from climate_index b where tm='195101' UNION ALL
select b.c130 as climate_value from climate_index b where tm='195101' ;