| From: | Decibel! <decibel(at)decibel(dot)org> |
|---|---|
| To: | Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: ranked subqueries vs distinct question |
| Date: | 2008-05-14 14:35:10 |
| Message-ID: | E572BB29-609B-4147-B6CC-5CB0697A46C5@decibel.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sam Mason | 2008-05-14 14:38:17 | Re: rounding problems |
| Previous Message | David McNett | 2008-05-14 14:28:50 | Re: ranked subqueries vs distinct question |