PG把多条记录合并成字符串,用逗号分隔
select array_to_string(
array(select quote_literal("HD_Code") from "public"."Hosp_Dept" where "HD_Code" in ('103001','103002','103') and "HD_SFMJ" is True), ';'
) as strs;
--------quote_literal
'103002';'103001'4
select array_to_string( array(select quote_ident("HD_Code") from "public"."Hosp_Dept" where "HD_Code" in ('103001','103002','103') and "HD_SFMJ" is True), ',' ) as strs; --------quote_ident "103002","103001"