On 06/12/09 19:32, Philip Stubbs wrote:
> Hi,
>
> I have been playing with mapnik to create some maps. It has been fun,
> but I am a bit lacking in Postgres SQL. Can anybody help me to adjust
> the following SELECT statement so that it will return a result set
> that consists of only one of each distinct 'name'?
>
> SELECT way,highway,aeroway,name,ref,char_length(ref) AS length,
> ST_Length(way) AS road_len,
> CASE WHEN bridge IN ('yes','true','1') THEN 'yes'::text ELSE
> bridge END AS bridge
> FROM planet_osm_line
> WHERE waterway IS NULL
> AND leisure IS NULL
> AND landuse IS NULL
> AND (name IS NOT NULL OR ref IS NOT NULL)
> ORDER BY road_len DESC
>
> Thank you all.
The default is SELECT ALL so try :-
SELECT DISTINCT ON (name) way,highway,aeroway,name,ref,char_length(ref)
AS length,.........
--
--------------------------------------------------------------
Discover Linux - Open Source Solutions to Business and Schools
http://discoverlinux.co.uk
--------------------------------------------------------------