<div class="jive-message-body">Dear All,
I have a table containing some records (Customer, DataOfPurchasments) where a customer might be purchasing in many different days. If I am willing to measure the inactivity period for this customer, what I have to do?
I was thinking to sort the customers ASC into a new table as to sort the rownum for each, the query is as below:
create table t as (Select customer,dataofPurch From sales) order by 1,2
then what I get is a sorted data regarding rownum as below:
Rownum, Customer, Dt
1, 1234, 01-Feb-2013
2, 1234, 05-Feb-2013
3, 1234, 06-feb-2013
4, 5678, 06-Feb-2013
5, 5678, 08-Feb-2013
The question, what I have to do if I want the output to be as below:
Customer, Date1,Date2,Inactivity
1234, 01-Feb-2013,05-Feb-2013,4
1234, 05-Feb-2013,06-Feb-2013,1
5678, 06-Feb-2013,08-Feb-2013,2
I was thinking in a query such as
Select Customer,Dt Date 1,X.Dt Date2 ,Dt-X.Dt
From t, (Select customer, Dt From T where rownum <rownum+1)X
where t.Customer = X.customer
group by Customer,Dt Date 1,X.Dt Date2 ,Dt-X.Dt
but that wasn't helpful. So, How can I solve my problem?
Regards;</div>
I have a table containing some records (Customer, DataOfPurchasments) where a customer might be purchasing in many different days. If I am willing to measure the inactivity period for this customer, what I have to do?
I was thinking to sort the customers ASC into a new table as to sort the rownum for each, the query is as below:
create table t as (Select customer,dataofPurch From sales) order by 1,2
then what I get is a sorted data regarding rownum as below:
Rownum, Customer, Dt
1, 1234, 01-Feb-2013
2, 1234, 05-Feb-2013
3, 1234, 06-feb-2013
4, 5678, 06-Feb-2013
5, 5678, 08-Feb-2013
The question, what I have to do if I want the output to be as below:
Customer, Date1,Date2,Inactivity
1234, 01-Feb-2013,05-Feb-2013,4
1234, 05-Feb-2013,06-Feb-2013,1
5678, 06-Feb-2013,08-Feb-2013,2
I was thinking in a query such as
Select Customer,Dt Date 1,X.Dt Date2 ,Dt-X.Dt
From t, (Select customer, Dt From T where rownum <rownum+1)X
where t.Customer = X.customer
group by Customer,Dt Date 1,X.Dt Date2 ,Dt-X.Dt
but that wasn't helpful. So, How can I solve my problem?
Regards;</div>