我想做的是以下内容:
我有一张这样的表:
ID; STATUS; ORIGIN
1 READY a
2 READY b
3 OPEN a
4 OPEN a
应该查询:
IDS; OPEN; READY; ORIGIN
1,3,4 2 1 a
2 0 1 b
到目前为止的查询:
SELECT ORIGIN,
SUM(CASE WHEN UPPER(STATUS) = 'OPEN' THEN 1 ELSE 0 END) AS OPEN,
SUM(CASE WHEN UPPER(STATUS) = 'READY' THEN 1 ELSE 0 END) AS READY,
<LIST_FUNC>(ID, ',') AS IDS
FROM TABLE
GROUP BY ORIGIN;
我正在寻找derby(<LIST_FUNC>
)中的函数,该函数通过聚合在组中进行ID列的串联。当然,签名可能看起来不同。
提前致谢!