SQL Server - ADD Previous day data Query - Asked By farrukh on 19-Dec-11 08:16 AM

Earn up to 10 extra points for answering this tough question.
 Hi All,

 I need a query that return result add previous day data in a range the result is below.


Month acutal values Results
1/1/2010 10 10
1/2/2010 20 30
1/3/2010 20 40
1/4/2010 20
1/5/2010 30 50
1/6/2010 20
1/7/2010 12 22
1/8/2010 20
1/9/2010 60 80
1/10/2010 20


Thanks
Hameeed
Anoop S replied to farrukh on 19-Dec-11 01:21 PM
Try using a correlated subquery.

select

    a.Month, a.acutal values,

    (

    select sum(b.acutal values)

    from t as b

    where b.acutal values = a.acutal values and b.Month <= a.Month

    ) as Result

from

    t as a;

GO
kalpana aparnathi replied to farrukh on 19-Dec-11 01:46 PM
Try this code:

select * from mvs_store_all_data_time_change
where mvs_creation_date > (getdate()-1)
farrukh replied to kalpana aparnathi on 25-Jan-12 03:35 AM
Anoop & Kalpana,

Both the quires works for me thanks you so much.


Regards,
Farrukh