Saya mencoba kueri berikut dan mencapai hasil yang diinginkan.
SELECT
LISTAGG(X, ',') WITHIN GROUP(
ORDER BY
X
) as result
FROM
(
SELECT
X,
SUM(LENGTH(X)) OVER(
ORDER BY
X
) LENGTH_X,
COUNT(1) OVER(
ORDER BY
X
) - 1 AS COMMAS
FROM
(
SELECT
LEVEL X
FROM
DUAL
CONNECT BY
LEVEL <= 20
)
)
GROUP BY
CEIL((LENGTH_X + COMMAS) / 15);
Keluaran:
Semangat!!