From: Josh Berkus <josh@agliodbs.com>
To: William Herring <wherring@mail.ifas.ufl.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: select with multiple occurences in same table
Date: Mon, 25 Jun 2001 15:37:39 -0700
Message-ID: <web-77065@davinci.ethosmedia.com> (raw)
In-Reply-To: <LNEOLDDDAKFHFMFOADPPCEDICAAA.wherring@mail.ifas.ufl.edu>
WIlliam,
> Table "inventorytrack"
> Attribute | Type | Modifier
> ------------+-----------+----------
> tattoo | text |
> past_group | text |
> ranch | text |
> ent_date | timestamp |
> indate | date |
>
Are you sure that you're using the most efficient data types for this
table? And where's your primary key?
> In the above table, I have multiple occurrences of ‘tattoo’.
> However, some
> of the tattoo’s have null value in ‘indate’, some do not. I would
> like to
> select those tattoos with a null indate, unless there is another
> identical
> tattoo in the table that has a date value in ‘indate’.
THis one is easy. However, I'm not sure exactly waht you want; the
sample return tuples you provided do not match what you asked for!
If you wanted to answer the question above:
SELECT * FROM inventorytrack
WHERE indate IS NULL
AND NOT EXISTS (
SELECT tattoo FROM inventorytrack it2
WHERE it2.tattoo = inventorytrack.tattoo
AND indate IS NOT NULL );
-Josh Berkus
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, wherring@mail.ifas.ufl.edu
Subject: Re: select with multiple occurences in same table
In-Reply-To: <web-77065@davinci.ethosmedia.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox