Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Relational Databases
Expertise: Beginner
Jul 12, 1999

Cumulative Summary in SQL

Question:
I need a summary-select which summaries cumulative values. This one works in Microsoft Access:
SELECT 
s.nl_item_id, s.nl_value, 
(
     SELECT sum(sub.nl_value) FROM TABLE1 sub 
     WHERE sub.nl_item_id<=s.nl_item_id
) AS kumul
FROM TABLE1 AS s;
How can I make it work using a BDE-DB2 alias?

Answer:
As far as I know, you can't do this in a single step on most server databases, especially traditional systems like DB2 and Oracle. MS SQL Server's TransactSQL (I think Access uses a variant of that SQL) allows you to shortcut a lot of stuff