From: William Herring <wherring@mail.ifas.ufl.edu>
To: pgsql-sql@postgresql.org
Subject: select with multiple occurences in same table
Date: Mon, 25 Jun 2001 17:08:39 -0700
Message-ID: <LNEOLDDDAKFHFMFOADPPCEDICAAA.wherring@mail.ifas.ufl.edu> (raw)
Table "inventorytrack"
Attribute | Type | Modifier
------------+-----------+----------
tattoo | text |
past_group | text |
ranch | text |
ent_date | timestamp |
indate | date |
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’. For example, I
might have:
tattoo | past_group | ranch | ent_date | indate
--------+----------------+--------+------------------------+------------
1039 | Barn2/Behind | Iberia | 2000-03-16 11:03:32-08 |
1039 | Across/Bubs | Iberia | 2000-12-28 14:57:13-08 | 2000-12-28
1832 | GardnerBlock#3 | Iberia | 2000-03-16 11:03:32-08 |
1832 | GardnerBlock#2 | Iberia | 2000-12-28 12:46:57-08 | 2000-12-28
1833 | Becker1 | Iberia | 2000-03-16 11:03:32-08 |
So the prospective SELECT would give back:
tattoo | past_group | ranch | ent_date | indate
1039 | Across/Bubs | Iberia | 2000-12-28 14:57:13-08 | 2000-12-28
1832| GardnerBlock#2 | Iberia | 2000-12-28 12:46:57-08 | 2000-12-28
1833| Becker1 | Iberia | 2000-03-16 11:03:32-08 |
Any suggestions on how to do this?
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: wherring@mail.ifas.ufl.edu
Subject: Re: select with multiple occurences in same table
In-Reply-To: <LNEOLDDDAKFHFMFOADPPCEDICAAA.wherring@mail.ifas.ufl.edu>
* 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