Re: ranked subqueries vs distinct question

Поиск
Список
Период
Сортировка
От Decibel!
Тема Re: ranked subqueries vs distinct question
Дата
Msg-id E572BB29-609B-4147-B6CC-5CB0697A46C5@decibel.org
обсуждение исходный текст
Ответ на Re: ranked subqueries vs distinct question  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: ranked subqueries vs distinct question
Re: ranked subqueries vs distinct question
Re: ranked subqueries vs distinct question
Список 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



Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: David McNett
Дата:
Сообщение: Re: ranked subqueries vs distinct question
Следующее
От: Sam Mason
Дата:
Сообщение: Re: rounding problems