This query returns the following results...
WITH t(wk, COST) AS
(SELECT wk, COST FROM myTable WHERE id = '345')
SELECT listagg(wk,',') WITHIN GROUP(ORDER BY wk) AS wks, COST
FROM t
GROUP BY COST;
...
WKS COST
----------------------
17, 18, 19, 21 446
26, 27, 28 588
Is it possible to create the following results where consecutive weeks are returned as from and to. (eg 1-10 rather than 1, 2, 3, 4,... etc)
WKS COST
----------------------
17-19, 21 446
26-28 588