I have a table with values like the following
Name DatePurchased QuantityPurchased
A 2/3/2012 1
A 2/4/2012 1
A 2/5/2012 2
B 2/2/2012 1
B 2/3/2012 2
I want to output the following
Name DatePurchased QuantityPurchased
A 2/3/2012 1
A 2/4/2012 2 // as I have purchased 2 upto this date
A 2/5/2012 4 // as I have purchased 4 upto this date
B 2/2/2012 1
B 2/3/2012 3
My query
SELECT Name, `DatePurchased` , SUM(QuantityPurchased)
FROM table1
GROUP BY DatePurchased
does not do the math right. I know whats wrong but can't figure out the solution.
Thanks
SUM()withCOUNT(). This may or may not work depending on what results you get currently; please post the output your current query generates.