Group By后如何在一行中设置记录

How to set record in one line after Group By

我想在Group By

之后将所有记录设置为一行,用,分隔

我的输入:

+ --------- + -------------- +
| Name      | Phone Number   |
+ --------- + -------------- +
| John      | 1234567        |
| John      | 1472583        |
| John      | 3698521        |
| John      | 7896541        |
+ --------- + -------------- +

我想要的输出

+ --------- + -------------------------------+
| Name      |           Phone Number         |
+ --------- + -------------------------------+
| John      | 1234567,1472583,3698521,7896541|
+ --------- + -------------------------------+

您正在寻找listagg()

select name, listagg(phone_number, ', ') within group (order by phone_number) as phone_numbers
from t
group by name;