Re: select with multiple occurences in same table

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: select with multiple occurences in same table
Дата
Msg-id web-77065@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на select with multiple occurences in same table  ("William Herring" <wherring@mail.ifas.ufl.edu>)
Список 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 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 it2WHERE it2.tattoo = inventorytrack.tattoo    AND indate IS NOT NULL
);

-Josh Berkus



______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


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

Предыдущее
От: "William Herring"
Дата:
Сообщение: select with multiple occurences in same table
Следующее
От: "Robby Slaughter"
Дата:
Сообщение: pl/pgSQL and escaping LIKE clauses