0

我是 Oracle SQL 的新手。我想得到这样的输出

    deptno         ename
    10               A
    20               b    
    30               c
    10               d
    10               e
    30               f  

作为

     deptno                 ename
       10                        a,d,e
       20                        b
       30                        c , f

在单个选择语句中?

4

1 回答 1

0
select deptno, listagg (lower(ename),', ') within group (order by ename) ename from
(
select 10 deptno,'A' ename from dual union all
select 20 deptno,'b' ename from dual union all
select 30 deptno,'c' ename from dual union all
select 10 deptno,'d' ename from dual union all
select 10 deptno,'e' ename from dual union all
select 30 deptno,'f' ename from dual   
)
group by deptno
于 2015-06-17T08:07:07.130 回答