如何在postgresql中从数组\返回到\字符串的和

如何在postgresql中从数组\返回到\字符串的和,postgresql,Postgresql,我需要从数组中只有整数值的数组_到字符串函数的求和结果 SELECT state_name, "ST_CODE" , dist_name , "DIST_CODE", subdist_name, "SUBDIST_CODE", array_to_string(array_agg(distinct jan_sale::numeric), ',') as super FROM village_details_new , aw WHERE

我需要从数组中只有整数值的数组_到字符串函数的求和结果

SELECT
    state_name,
    "ST_CODE" ,
    dist_name ,
    "DIST_CODE",
    subdist_name,
    "SUBDIST_CODE",
    array_to_string(array_agg(distinct jan_sale::numeric), ',') as super
FROM village_details_new , aw
WHERE
    "ST_CODE"::integer=3
    AND village_details_new.aw_code::integer = aw.aw_code::integer
group by
    "SUBDIST_CODE",
    state_name,
    "ST_CODE" ,
    dist_name ,
    "DIST_CODE",
    subdist_name
order by "SUBDIST_CODE"
我需要一笔钱

sum(array_to_string(array_agg(distinct jan_sale::numeric), ',') as super) 
但它不起作用,请帮忙

"Punjab";"03";"Gurdaspur";"0301";"Dhar Kalan";"0301001";"10.1620708"
"Punjab";"03";"Gurdaspur";"0301";"Pathankot";"0301002";"8.7883687"
"Punjab";"03";"Gurdaspur";"0301";"Gurdaspur";"0301003";"0"
"Punjab";"03";"Gurdaspur";"0301";"Batala";"0301004";"0"
"Punjab";"03";"Gurdaspur";"0301";"Dera Baba Nanak";"0301005";"5.6477731"
"Punjab";"03";"Kapurthala";"0302";"Bhulath";"0302001";"6.6241262"
"Punjab";"03";"Kapurthala";"0302";"Kapurthala";"0302002";"12.6775959"
"Punjab";"03";"Kapurthala";"0302";"Sultanpur Lodhi";"0302003";"3.1599889"
"Punjab";"03";"Kapurthala";"0302";"Phagwara";"0302004";"3.3310623,8.7898848"
"Punjab";"03";"Jalandhar";"0303";"Shahkot";"0303001";"14.2610899"
"Punjab";"03";"Jalandhar";"0303";"Nakodar";"0303002";"14.2610899"

等待你的实际数据是什么?它是一个数组吗?你怎么知道jan_sale是什么?源数据是什么样子的?它是如何构造的?这个
aw
表是什么?它的数据是什么?这就是数组所在的位置吗?如何对逗号分隔的字符串列表进行“求和”?“不工作”不是有效的Postgres错误消息。yaa我需要逗号分隔的整数列表的总和如何做???在将它们放入逗号分隔的列表之前求和如何做,请指定我编写了整个sql。。。。
sum(distinct jan_sale)::numeric as super