MySQL Forums
Forum List  »  Newbie

Re: Cumulative sum
Posted by: João Mota
Date: November 29, 2006 11:48AM

Thanks a lot... I've changed something though 'cause the first row was showing a null sum value

SELECT a.id,
a.in,
a.out,
(SELECT SUM( in - out )
FROM mytable b
WHERE b.id <= a.id) AS run_sum
FROM mytable a
ORDER BY id

Options: ReplyQuote


Subject
Written By
Posted
November 29, 2006 11:14AM
November 29, 2006 11:23AM
Re: Cumulative sum
November 29, 2006 11:48AM
December 04, 2007 04:54PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.