【问题标题】:Group by one column with different values ORACLE [duplicate]按具有不同值的一列ORACLE [重复]
【发布时间】:2020-02-24 09:49:21
【问题描述】:

我有下一张桌子:

号码 |元素 --------+---------- 1 |元素1 1 |元素2 1 |元素3 2 |元素5 2 |元素6 2 |元素7

我正在通过 select 搜索一个组,返回下一个:

1 |元素1元素2元素3 2 |元素5元素6元素7

我试过了:

Select number, element from table group by number;

但它返回给我not a group by expresion

如果可能的话,任何人都知道我怎样才能做到这一点?

感谢您的宝贵时间

【问题讨论】:

标签: sql oracle string-aggregation


【解决方案1】:

使用listagg

Select number_, listagg(element) within group (order by element) as elements
From your_table
Group by number_

加油!!

【讨论】:

    猜你喜欢
    • 2020-11-23
    • 2018-04-11
    • 1970-01-01
    • 2019-06-30
    • 2017-04-23
    • 1970-01-01
    • 2022-07-18
    • 2013-04-04
    • 1970-01-01
    相关资源
    最近更新 更多