postgres crosstab fixed multiple columns

The original data is as follows

SQL is as follows

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	
);

The results are as follows

Guess you like

Origin blog.csdn.net/baidu_31405631/article/details/113618360