Database Reference
In-Depth Information
the_geom, gid AS gid FROM
chp04.voronoi_test_points
) AS point_dump
),
astextcomma AS (
SELECT replace(pstring, ' ', ',') AS pstring
FROM astext
),
startingbracket AS (
SELECT replace(pstring, 'POINT(', '[') AS
pstring
FROM astextcomma
),
endingbracket AS (
SELECT replace(pstring, ')', ']') AS pstring
FROM startingbracket
)
SELECT * FROM endingbracket;
You will get the following result:
pstring
---------
[5,7]
[2,8]
[10,4]
[1,15]
[4,9]
[8,3]
[5,3]
[20,0]
(8 rows)
Now,itgetsinteresting.Wewanttogofromacolumnofthesenumberstoacomma-
delimitedconcatenatedlistofthem.PostgreSQLhasaverynicefunctionforjustthis
purpose, STRING_AGG . It will require an order by number, so we will leverage our
Search WWH ::




Custom Search