MySQL Forums
Forum List  »  InnoDB

Re: Accumulated Sum
Posted by: Jay Pipes
Date: June 26, 2005 11:16PM

My guess is that for this scenario, you'll get poorer performance with UDFs (either MySQL or Postgres) compared to the >= predicate. Though, I'd love to see some benchmarks... I just don't have the time right now...perhaps an article soon...

Anyway, for your question. Try this:

SELECT s1.Date, s1.Code, s1.StockCode, s1.IN, SUM(s2.IN) as 'RunSum'
FROM Stocks s1
INNER JOIN Stocks s2
ON s1.StockCode = s2.StockCode
AND s1.Code >= s2.Code;

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
7670
June 26, 2005 07:36AM
3470
June 26, 2005 07:48AM
3833
June 26, 2005 10:07PM
Re: Accumulated Sum
3542
June 26, 2005 11:16PM
2953
June 27, 2005 12:32AM
2754
June 27, 2005 01:06AM


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.