Skip to content

Instantly share code, notes, and snippets.

@zazk
Created December 30, 2014 19:02
Show Gist options
  • Select an option

  • Save zazk/de2133faa204d5bb4ffb to your computer and use it in GitHub Desktop.

Select an option

Save zazk/de2133faa204d5bb4ffb to your computer and use it in GitHub Desktop.
Concatenate ID Oracle 10g
SELECT SUBSTR (SYS_CONNECT_BY_PATH (id_reporte , ','), 2) csv
FROM (SELECT id_reporte , ROW_NUMBER () OVER (ORDER BY id_reporte ) rn,
COUNT (*) OVER () cnt
FROM geo_reporte_servicios WHERE ANO='2014' AND COD_CA='CEM001' AND UBIGEO='030101' AND COD_SERV='SER001')
WHERE rn = cnt
START WITH rn = 1
CONNECT BY rn = PRIOR rn + 1
--RESULT
-- 2163,2165,2167,2169,2171,2173,2175,2177,2179,2181,2183,2185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment