how to effectively SELECT new "customers"

Поиск
Список
Период
Сортировка
От Jan Ostrochovsky
Тема how to effectively SELECT new "customers"
Дата
Msg-id 1001132708.567696.1393510818245.JavaMail.root@mobiletech.sk
обсуждение исходный текст
Ответы Re: how to effectively SELECT new "customers"  (David Johnston <polobo@yahoo.com>)
Список pgsql-sql
<div style="font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000"><pre>Hello,</pre><pre>I
amsolving following task and it seems hard to me to find effective solution. Maybe somebody knows how to help
me:</pre><pre>Wehave table "purchases" and each one record is identified by "customer_id".</pre><pre>We want to know
notonly how many different customers did at least one purchase per time period, grouped by time periods</pre><pre>(easy
task:"COUNT(DISTINCT customer_id)" with "GROUP BY period"), but also to know how many NEW customers there
were.</pre><pre>Wedefine new customer as customer_id, which had first record in table "purchases" after 12 month of
inactivity(no record</pre><pre>in table "purchases" previous 12 months).</pre><pre>I have found one solution, but it is
veryslow and ugly. I tried several other concepts, but without success.</pre><pre>Any hint could be helpful for me.
Thanksin advance!</pre><pre>Jano</pre></div> 

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

Предыдущее
От: ALMA TAHIR
Дата:
Сообщение: Function Issue
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Function Issue