原始数据如下
SQL 如下
select split_part(tnm_time, '~', 1) as tnm
, split_part(tnm_time, '~', 2)::timestamp as tims
,"616"
,"622"
,"631"
,"648"
,"652"
,"699"
from crosstab(
'select tp_id||''~''||dt,type1,value from tmp_test '
,'select distinct type1 from tmp_test '
)AS (
"tnm_time" text
,"616" text
,"622" text
,"631" text
,"648" text
,"652" text
,"699" text
);
结果如下