pgsql 行转列 语法示例
SELECT
r.*,
KEY AS COLUMNNAME,
VALUE
:: INT COLUMNVALUE
FROM
( SELECT T.*, row_to_json ( T.* ) AS jsonStr FROM ly_zlgz_zlhyjl_zdjb T ) AS r
JOIN LATERAL json_each_text ( r.jsonStr ) ON ( KEY IN ( 'gjfks','gjfws','gjzys','gjzzs' ) )
评论区