× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Found this example of new OLAP functions coming to i7.3 DB2. I've been
wanting a way to calculate a rolling subtotal for sometime. This will
eliminate the break point totaling, or extra "grouping sets" I've used in
the past.

http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/sqlp/rbafyolap.htm

Example: Using OLAP Aggregates and CUME_DIST


Suppose that you want to find the rolling sum of the salaries for employees
in department D11 and also the distribution of the salary.


SELECT ROW_NUMBER() OVER() AS ROW, LASTNAME, SALARY,
SUM(SALARY) OVER(ORDER BY SALARY
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS
ROLLING_TOTAL_RANGE,
SUM(SALARY) OVER(ORDER BY SALARY
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS
ROLLING_TOTAL_ROWS,
DECIMAL(CUME_DIST() OVER (ORDER BY SALARY),4,3) AS DISTRIBUTION
FROM EMPLOYEE
WHERE WORKDEPT = 'D11'
ORDER BY SALARY




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.