Re: Sorting street addresses - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: Sorting street addresses
Date
Msg-id 41816ADD.9030002@commandprompt.com
Whole thread Raw
In response to Re: Sorting street addresses  (Richard Poole <rp@guests.deus.net>)
List pgsql-general
Richard Poole wrote:
> 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.

You could also add a function index that would help speed things along.

Sincerely,

Joshua D. Drake



>
> Richard
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)


--
Command Prompt, Inc., home of PostgreSQL Replication, and plPHP.
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL

Attachment

pgsql-general by date:

Previous
From: Richard Poole
Date:
Subject: Re: Sorting street addresses
Next
From: "Jim C. Nasby"
Date:
Subject: Turning a subselect into an array