Hi,
I got a number of transactions for a given day. I’m trying to calculate the sum of transactions for the Previous 7 days (not including the current day)
e.g
CREATE TABLE #Test
(
Code varchar(5),
TransDate date,
NoOfTran INT
)
INSERT INTO #Test
VALUES
('ABC', '2013-02-10', 21),
('ABC', '2013-02-07', 6),
('ABC', '2013-02-06', 5)
Result I am looking for….
Code TransDate Last7DaysNoOfTran
ABC 2013-02-10 11
ABC 2013-02-07 5
ABC 2013-02-06 0
any ideas?