问题描述
大家好...
我想遍历一次select的结果并将它们收集到一个唯一的字符串中,以实现整个结果,查询将获取单列的一组行
从表名tbl中选择tbl.column_name,其中(条件)
我想获取此查询的所有结果,并使用一些字符将它们分开后将它们放入字符串nvarchar2(4000)中.
在此先感谢...
hello everybody ...
i want to loop through the results of a select and gather them into a unique string implements the whole result , the query fetches a set of rows of a single column
select tbl.column_name from table_name tbl where (condition)
I want to get all the results of this query and put them into a string nvarchar2(4000) after separating them using some characters
thanks in advance...
推荐答案
select
deptno,
listagg (ename, ',')
WITHIN GROUP
(ORDER BY ename) enames
FROM
emp
GROUP BY
deptno
将为您提供所有部门的每个部门的逗号分隔列表.
如果您有较早的版本,还有其他方法,但是除了列出它们之外,我将为您提供链接 [ ^ ] intead.
will give you all employenames as a comma separated list per department.
There are other methods if you have earlier versions, but instead of listing them I''ll give you a link[^] intead.
这篇关于循环选择结果并在操作中使用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!