如何在 Oracle 中聚合具有多个列的多行?
How to aggregrate multiple rows with more than one columns in Oracle?
我有一个 table(名为 'games'),它包含三列:天气、体育和客户
weather sports customer
sun volleyball Randy
sun volleyball Lau
sun gym Ryan
sun gym Rachel
table待
weather sports customer
sun volleyball Randy, Lau
sun gym Ryan, Rachel
我使用了以下 LISTAGG 命令,但它给我错误提示 'not a group by expression'
SELECT
weather, sports,
LISTAGG(customer, ',') WITHIN GROUP (ORDER BY sports) "Customer"
FROM games
GROUP BY customer;
GROUP BY
需要包含 未聚合的 列。它们定义结果集中的每一行:
SELECT weather, sports,
LISTAGG(customer, ',') WITHIN GROUP (ORDER BY sports) as Customers
FROM games
GROUP BY weather, sports;
我有一个 table(名为 'games'),它包含三列:天气、体育和客户
weather sports customer
sun volleyball Randy
sun volleyball Lau
sun gym Ryan
sun gym Rachel
table待
weather sports customer
sun volleyball Randy, Lau
sun gym Ryan, Rachel
我使用了以下 LISTAGG 命令,但它给我错误提示 'not a group by expression'
SELECT
weather, sports,
LISTAGG(customer, ',') WITHIN GROUP (ORDER BY sports) "Customer"
FROM games
GROUP BY customer;
GROUP BY
需要包含 未聚合的 列。它们定义结果集中的每一行:
SELECT weather, sports,
LISTAGG(customer, ',') WITHIN GROUP (ORDER BY sports) as Customers
FROM games
GROUP BY weather, sports;