此查询返回以下结果...
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
是否可以创建以下结果,其中连续周返回为 from 和 to。(例如 1-10 而不是 1, 2, 3, 4,... 等)
WKS COST
----------------------
17-19, 21 446
26-28 588