Hi,
I am totaly new to SQL. I have a database, where I have an ID Number as well as a Price Number which I would like to add up for the Items I bought in each week so that I know how much I spend in each week. It looks something like this:
ID Price Purchased Week Summary
1 199 1 -
2 79 1 -
... ... ..
20 150 5 -
I tried something like this, but it won't work, maybe someone can help me, cause it's getting much more complicated.. I know the following is very wrong...
DECLARE @summary INT
DECLARE @id INT
SET @summary = 0
SET @id = 0
WHILE (@id < 5000)
BEGIN
SELECT DISTINCT Price FROM PurchasesTest
WHERE Week = 1
SET @summary = @summary + Price
INSERT INTO PurchasesTest (Summary) VALUES = @summary
END
Please help...
Tnx