Oracle Sql select 一行中的所有值而不使用聚合函数和过程

Oracle Sql select all values in a row without using aggregate functions and procedures

我有这个代码:

select eto.id,( epe.surname || ' ' || epe.name  || ' ' || epe.patronymic) fio
                        from employee_trip_orders eto
                        left join employee_card_order_links ecol
                        on eto.id = ecol.trip_order_id
                        left join employee_trip_cards etc
                        on ecol.trip_card_id = etc.employee_trip_card_id 
                        left join eip_persons.employees epe
                        on etc.employee_id = epe.employee_id
                        where eto.id=2223
                        order by eto.id

和执行此代码的结果

id     fio
------------
2223 John Smith Brown
2223 Jack Orange Apple
2223 Jordan Stinky Tomato

我想将其转换为带有逗号分隔符的单行

id     fio
-------------------------------
2223 |  John Smith Brown,
     |  Jack Orange Apple,
     |  Jordan Stinky Tomato
-------------------------------

如何在不使用外部函数、分组依据和聚合函数的情况下实现这一点?谢谢

您可以使用 connect by 查询来完成,但它比简单的 listagg().

更慢也更复杂
select id, ltrim(sys_connect_by_path(fio, ', '), ', ') names
  from (select row_number() over (partition by id order by fio) rn, id, fio from t)
  where connect_by_isleaf = 1
  connect by id = prior id and rn = prior rn + 1
  start with rn = 1

dbfiddle