• Subject: Re: SQL pivot question
  • From: "R. Bruce Hoffman, Jr." <rbruceh@xxxxxxxxxxxxx>
  • Date: Mon, 13 Nov 2000 11:41:59 -0500

-----Original Message-----
From: Bart Verweijen <bart.verweijen@advalvas.be>
To: Midrange L <MIDRANGE-L@midrange.com>
Date: Monday, November 13, 2000 9:54 AM
Subject: SQL pivot question

>T1."CHL1UC" "c1",

... snip ...

>This works so far. This gives me sums on the lowest level of my query. But
>also need sums on higher group levels... Anyone know if this is possible ?
>It would help me A LOT !

Yes, what you are looking for is the ROLLUP function that is available in
DB2 UDB. Only problem is that it is not on the 400 "version" of UDB.

The only way to do this on the 400 would be to build each of the rollups
separately (distinct SQL selects, grouped appropiately with nulls or blanks
or some value for the control fields) and then use the UNION operator to
splice the results together and then order by...

Ugly but functional.

R. Bruce Hoffman, Jr.
 -- IBM Certified Specialist - AS/400 Administrator
 -- IBM Certified Specialist - RPG IV Developer

"Those who would give up essential Liberty,
  to purchase a little temporary Safety,
  deserve neither Liberty nor Safety."

     - The Papers of Ben Franklin

| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com

This thread ...


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

This mailing list archive is Copyright 1997-2020 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].