Re: SQL question: checking all required items

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: SQL question: checking all required items
Дата
Msg-id 46BDFB49.2020108@iol.ie
обсуждение исходный текст
Ответ на Re: SQL question: checking all required items  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Список pgsql-general
On 10/08/2007 21:42, Scott Marlowe wrote:

> Show us the query when you're done, I'm sure there are enough folks
> who'd like to see your solution.

Here's what I came up with:

   select distinct ip.person_id from items_for_people ip
   where exists (
     (
       select item_id from items
       where is_required = true
     )
     except
     (
       select ip2.item_id from items_for_people ip2
       inner join items i on (ip2.item_id = i.item_id)
       where ip2.person_id = ip.person_id
       and i.is_required = true
     )
   )

This finds all those who don't have all the required items, whatever
else they may have.

Comments and improvements are welcome!

Thanks for the help,

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

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

Предыдущее
От: Hannes Dorbath
Дата:
Сообщение: Re: virtual database
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: timestamp skew during 7.4 -> 8.2 upgrade