Hi All
Can anyone help me out in this.
In my database i have stored value for new customer in cache table using below query.
But i want to do the same in SSAS without using cache table.
Here senario is i want count of customers present in current date but not present in previous date(New customers).
For e.g. I want count of customers present in '2013-01-05' but not present in '2013-01-04' then present in '2013-01-04' but not in '2013-01-03' so on...
insert into tb_Date
select distinct Date,Freq_ID from Tb_Customer
order by Date desc
Declare @count int,@CountEnd int
set @count = 1
set @CountEnd = (select count (1) from tb_Date)
Declare @currnt_date datetime
Declare @compr_date datetime
while (@count < @CountEnd)
begin
set @currnt_date = (select Date from tb_Date where ID = @count )
set @compr_date = (select top 1 Date from tb_Date where Date < @currnt_date)
insert into New_Customer_Count
select COUNT(Distinct Customer_id) as Total_Count
from Tb_Customer A
where Date = @currnt_date
and Customer_id not in
(
select Customer_id from Tb_Customer B
where Date = @compr_date
)
set @count = @count + 1
end
thanks in advance
Regards,
Swapnil