Select by priority

Поиск
Список
Период
Сортировка
От kumar1@home.com (Prasanth A. Kumar)
Тема Select by priority
Дата
Msg-id m3ya33co8g.fsf@C654771-a.frmt1.sfba.home.com
обсуждение исходный текст
Ответы Re: Select by priority  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-sql
I need some suggestions on how to construct a particular select that I
need. I have a table of addresses where the primary key is the
persons_id and a address_type field. The address_type field is a
character which specifies whether the address is for the home, work,
or mailing. A person can have multiple addresses though only one of a
type. What I want to do is select a list of address for each distinct
individual but wish to select based of priority that if the mailing
address exists, I get that one only. If there is no mailing address, I
want the home address and failing that, get the work address. Is it
within the realm of sql to be able to do that?

-- 
Prasanth Kumar
kumar1@home.com


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Applying SUM twice in the same query.
Следующее
От: "omid omoomi"
Дата:
Сообщение: Re: Select by priority