200000#500000# Not: [email protected]

问题描述 投票:1回答:1

我想让listagg的返回值有序化,这样就像。

[email protected] | 200000#500000# 

Not: 

[email protected] | 500000#200000#

下面是一些示例代码

我注意到如果我把 ('200000', '[email protected]') 行,它做了我想做的事情,但我不能在CTE中进行排序,所以对如何得到同样的结果有点迷茫。

WITH TAB (client, email) AS 
(
VALUES 
  ('500000', '[email protected]'), 
  ('200000', '[email protected]')
)
SELECT email, listagg(trim(client) || '#', '')
FROM TAB a
GROUP BY email;
sql db2 db2-400
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.