我的数据表如下所示:
CustID CustName OrderNumber ...
001 John Smith 1234
002 kelly smith 1235, 4512
我希望我的记录集返回如下内容:
docker-compose
如果客户有 1 个以上的订单,则以逗号分隔值的形式返回订单#...
答案 0 :(得分:0)
你可以使用函数listagg()
select custid,custname,
(select listagg(t.ordernumber, ', ') within group (order by
t.ordernumber) from table t where t.custid = table.custid and
t.custname = table.custname) as ordernumber
from table