From: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
---|---|
To: | "William Herring" <wherring(at)mail(dot)ifas(dot)ufl(dot)edu> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: select with multiple occurences in same table |
Date: | 2001-06-25 22:37:39 |
Message-ID: | web-77065@davinci.ethosmedia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice pgsql-sql |
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 tattoos 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(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | William Herring | 2001-06-26 00:08:39 | select with multiple occurences in same table |
Previous Message | james | 2001-06-25 19:52:55 | any good resources on making network connections to postgresql out there? |
From | Date | Subject | |
---|---|---|---|
Next Message | William Herring | 2001-06-26 00:08:39 | select with multiple occurences in same table |
Previous Message | Tom Lane | 2001-06-25 18:01:11 | Re: Problems using a rule with the WHERE clause |