【发布时间】:2019-09-20 07:09:02
【问题描述】:
我在 postgresql 10 中的查询,在 GROUP 子句中使用时引发错误
错误:函数 string_agg(字符变化,未知,整数)确实 不存在
我在和 atrelation 有桌子。 at 具有唯一的 id 和描述,而 atrelation 存储多个交易,其中包含相关 at 和交易行 id 的代码。例如
id 为 6 的产品行有一个列名称标签,其值为 service5% 和 contco4.5%
id 为 5 的产品行具有标签值 service5%
我需要显示 2 行,即第 6 行和第 5 行。
第5行显示列标签值'service5% and contco4.5%'
第 6 行显示列标记值 'service5%'
select atrelation.id,
string_agg(at.description, ' and ' ) within GROUP (ORDER BY atrelation.id ) as tag1
from at, atrelation
where atrelation.id = atrelation.atid
group by atrelation.id
order by atrelation.id desc;
上面的查询引发以下错误,
ERROR: function string_agg(character varying, unknown, integer) does not exist
LINE 1: select atrelation.purchase_order_line_id as id, string_agg(a...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function string_agg(character varying, unknown, integer) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 49
【问题讨论】:
标签: postgresql string-aggregation