<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>