Question

wish my query the database to return me only one column!

select  longitude,  latitude  
from  mytable;
longitude       latitude
42.74575        -5.096483
42.745567       -5.097
42.745          -5.098717

I wanted to like this:

-42.74575 -5.096483,   -42.745567 -5.097,   -42.745 -5.098717
Was it helpful?

Solution

select string_agg(longitude::text||' '||latitude::text, ',')
from mytable

OTHER TIPS

I believe that is what you need ...

SELECT to_char(longitude, 'FM9999') || '  ' || to_char(latitude, 'FM9999') FROM mytable

If you don't know how many digits there are, just estimate the maximum: 'FM999999999999999999'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top