what I want to do is the following:
I have a table like this:
ID; STATUS; ORIGIN
1 READY a
2 READY b
3 OPEN a
4 OPEN a
This should be queried to:
IDS; OPEN; READY; ORIGIN
1,3,4 2 1 a
2 0 1 b
The query so far:
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;
I am looking for a function in derby (<LIST_FUNC>
), that does the concatenation of the ID column during the group by aggregation. Of course, the signature may look different.
Thanks in advance!