dcsimg
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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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