Re: Sorting street addresses - Mailing list pgsql-general

From Richard Poole
Subject Re: Sorting street addresses
Date
Msg-id 20041028213124.GC11905@guests.deus.net
Whole thread Raw
In response to Sorting street addresses  (Robert Fitzpatrick <robert@webtent.com>)
Responses Re: Sorting street addresses
Re: Sorting street addresses
List pgsql-general
On Thu, Oct 28, 2004 at 03:36:00PM -0400, Robert Fitzpatrick wrote:

> I would like all those on the same street grouped together. Is there any
> tricks to getting the street names sorted first, possibly where numbers
> and strings separate?

You could do something like

CREATE FUNCTION streetname(text) RETURNS text AS '
    SELECT substring($1 FROM ''[a-zA-Z ]+$'')
' LANGUAGE 'SQL';

and then add an ORDER BY streetname(address) to your select.

Richard

pgsql-general by date:

Previous
From: CSN
Date:
Subject: Derived tables?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Sorting street addresses