Re: ranked subqueries vs distinct question - Mailing list pgsql-general

From Decibel!
Subject Re: ranked subqueries vs distinct question
Date
Msg-id E572BB29-609B-4147-B6CC-5CB0697A46C5@decibel.org
Whole thread Raw
In response to Re: ranked subqueries vs distinct question  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Responses Re: ranked subqueries vs distinct question  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Re: ranked subqueries vs distinct question  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Re: ranked subqueries vs distinct question  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
List pgsql-general
On May 14, 2008, at 9:07 AM, Karsten Hilbert wrote:

> That doesn't work, unfortunately, because the urb (cities)
> table doesn't have the zip code. That's stored in a street
> table which foreign keys into the urb table.


SELECT name, zip, zip='04317' AS zipmatch
     FROM urb LEFT JOIN streets ON (streets.urb_id = urb.urb_id )
     ORDER BY zipmatch DESC, name
;

Of course you'll need to adjust the table and field names appropriately.

Someone should probably teach the gnumed folks about schemas, too... ;)
--
Decibel!, aka Jim C. Nasby, Database Architect  decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828



Attachment

pgsql-general by date:

Previous
From: David McNett
Date:
Subject: Re: ranked subqueries vs distinct question
Next
From: Sam Mason
Date:
Subject: Re: rounding problems