Hi,
Check below example, hope this will help you...
Day1 | count1
2015-10-01 12:38:19.487 | 100
2015-10-02 12:38:26.253 | 50
2015-10-03 12:38:33.540 | 150
2015-10-04 12:38:43.530 | 100
SELECT DAY(day1) as DayCount,
count1 as NoOfCustomer,
Count1 + ISNULL((SELECt SUM(count1) from Stats_Test B where DAY(B.Day1) < DAY(A.Day1)),0) as TotalNoOfCustomer,
(Count1 + ISNULL((SELECt SuM(count1) from Stats_Test B where DAY(B.Day1) < DAY(A.Day1) ),0))/DAY(day1) as AvGNoOfCustomer
from
Stats_Test A
DayCount | NoOfCustomer | TotalNoOfCustomer | AvGNoOfCustomer
1 | 100 | 100 | 100
2 | 50 | 150 | 75
3 | 150 | 300 | 100
4 | 100 | 400 | 100
You can customize above query to fit in your requirement.
Check Your Query...hope it should work as i have not run this.
Select X.br_name,
X.entry_date,
X.no_of_cust,
(X.no_of_cust+ ISNULL((SELECt SuM(X.no_of_cust) from X B where DAY(B.entry_date) < DAY(X.entry_date) ),0))/DAY(X.entry_date) as AvgCount
(
select branch.br_name,
tran_date as entry_date,
count(distinct slip_no) as no_of_cust
from rem_upload,branch
where rem_upload.location_id = branch.br_code
and ( ( rem_upload.location_id like '002' )
AND ( rem_upload.tran_date ='01/01/2015' )
AND ( rem_upload.tran_date = '12/10/2015' ) )
group by branch.br_name,tran_date
) X
Cheers