gpt4 book ai didi

sql - 如何排序由XMLAGG函数聚合的字段?

转载 作者:行者123 更新时间:2023-12-04 21:22:18 32 4
gpt4 key购买 nike

我有下表:

Part_number   seq_nbr    Super_narrative
1 1 When replacing
1 2 part with following parts
1 3 note:follwing are now available
1 4 with the organization

我正在使用XMLAGG将super_narrative聚合在对应于part_number的1行中。
SELECT serv_part_nbr, rtrim (xmlagg (xmlelement (e, Super_narrative || ', ')).extract ('//text()'), ',') PHRASE_TEXT 
FROM BL_MACS_SUPERSEDENCE_NOTE
GROUP BY part_number

但是我想根据 super_narrative聚合 seq_nbr

怎么做??

最佳答案

您没有提到DBMS,但是一个疯狂的猜测是:

SELECT serv_part_nbr
, rtrim (xmlagg (xmlelement(e, Super_narrative || ', ') order by seq_nbr ).extract ('//text()'), ','
) PHRASE_TEXT
FROM BL_MACS_SUPERSEDENCE_NOTE
GROUP BY part_number

关于sql - 如何排序由XMLAGG函数聚合的字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23600501/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com