×
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.
 
Hi Darryl,
I adapted the following from Example 3 at 
https://www.ibm.com/docs/en/db2-for-zos/11?topic=subselect-examples-grouping-sets-rollup-cube-queries
SELECT co, account, invoice#, sum(amount)
  FROM MyFile
 GROUP BY ROLLUP (co, account, invoice#)
 ORDER BY co, account, invoice#;
Co   Account    Invoice#    Amount
AA    1234        Inv1       10.00
AA    1234        Inv2       15.00
AA    1234        -          25.00
AA    -           -          25.00
BB    5678        Inv3       20.00
BB    5678        Inv5       13.00
BB    5678        -          33.00
BB    -           -          33.00
-     -           -          58.00
I'm not sure if there's a way to eliminate the totals you don't want.
--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx
pdow@xxxxxxxxxxxxxx
/
On 10/31/2022 11:04 AM, a4g atl wrote:
I cannot find my notes on this and I do not remember what this group is
called to look it up. Hoping you can assist.
I need to run a SELECT over a file and have totals printed at the break.
Example
Co    Account   Invoice#   Amount
AA    1234        Inv1             10.00
AA     1234       Inv2              15.00
Total AA 1234                       25.00
BB      5678      Inv3              20.00
BB      5678      Inv5               13.00
Total BB 5678                        33.00
Total BB                                  58.00
How do I build the SQL statement?
TIA, Darryl Freinkel.
As an Amazon Associate we earn from qualifying purchases.
	
 
This mailing list archive is Copyright 1997-2025 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.