Re: Select by priority

From: kumar1(at)home(dot)com (Prasanth A(dot) Kumar)
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Select by priority
Date: 2000-07-16 08:15:30
Message-ID: m3og3ycwyl.fsf@C654771-a.frmt1.sfba.home.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"omid omoomi" <oomoomi(at)hotmail(dot)com> writes:

> Hi,
> How about ordering by Address_type ? only needs to have 1, 2, 3 as
> different address types in your desired order. like :
>
> select person_id , address where address in not null order by address_type
> limit 1 ;
>
> sure you can change the limit if you wish more addresses.
> hope that helps
> Omid Omoomi
>
> >From: kumar1(at)home(dot)com (Prasanth A. Kumar)
> >To: pgsql-sql(at)postgresql(dot)org
> >Subject: [SQL] Select by priority
> >Date: 15 Jul 2000 10:11:43 -0700
> >
> >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?
<snip>

I think the order thing will work though I have no choice of using
numbering for the address_type as I am working off a pre-existing
database. They are using a mnemonic char type. I am essentially batch
downloading and processing this and other database tables for query
and presentations using web pages. BTW, does the 'limit' feature exist
in Oracle? The main database I am extracting data from is Oracle...

--
Prasanth Kumar
kumar1(at)home(dot)com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2000-07-16 14:45:54 Re: Select by priority
Previous Message omid omoomi 2000-07-16 00:51:47 Re: Select by priority