1.行數據使用於逗號分隔顯示
select string_agg(v,',') v from( select '0.0' v union all select '10.0' v union all select '20.0' v union all select '30.0' v union all select '40.0' v )s;
結果:
1.以逗號分隔的數據轉為行顯示
select regexp_split_to_table(v, ',') v from(select '0.0,10.0,20.0,30.0,40.0'::text v)s;
結果:
3.1.以逗號分隔的數據轉為列顯示
select s[1] v1,s[2] v2,s[3] v3,s[4] v4,s[5] v5, split_part(s1,',', 1) s1, split_part(s1,',', 2) s2, split_part(s1,',', 3) s3, split_part(s1,',', 4) s4, split_part(s1,',', 5) s5 from( select regexp_split_to_array('0.0,10.0,20.0,30.0,40.0', ',') s,'0.0,10.0,20.0,30.0,40.0'::varchar s1 )tt;
結果: