Re: how to effectively SELECT new "customers"

Поиск
Список
Период
Сортировка
От Jan Ostrochovsky
Тема Re: how to effectively SELECT new "customers"
Дата
Msg-id 2042881838.607913.1393690147570.JavaMail.root@mobiletech.sk
обсуждение исходный текст
Ответ на Re: how to effectively SELECT new "customers"  (David Johnston <polobo@yahoo.com>)
Ответы Re: how to effectively SELECT new "customers"  (David Johnston <polobo@yahoo.com>)
Список pgsql-sql
Without incorporating additional meta-data about the purchases onto the
customer table the most basic solution would be:

SELECT DISTINCT customer_id FROM products WHERE date > (now() - '12
months'::interval)
EXCEPT
SELECT DISTINCT customer_id FROM products WHERE date <= (now() - '12
months'::interval)

---

Another solution:
WHERE ... >12 AND NOT EXISTS (SELECT ... WHERE <= 12)

David J.
subsidiary matter: in what circumstances is better to use EXCEPT and in what NOT EXISTS?

are those equivalents? tried to google their comparison, but no relevant results found for PostgreSQL

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

Предыдущее
От: Jan Ostrochovsky
Дата:
Сообщение: Re: how to effectively SELECT new "customers"
Следующее
От: David Johnston
Дата:
Сообщение: Re: how to effectively SELECT new "customers"