> Does anyone know if it's possible for Query/400 to do calculations on > it's own calculated totals (i.e. calculate margin % from it's running > totals)...and print them??? Yes, however there are some gotchas when working with calculated totals. First off, in the calculation section you can create new fields that are calculated from prior fields, or date stuff based on current day you running the thing, or constants ... we use some like '---------- >' (arrow head) to indicate that perhaps some field should be changed to some other value by our personnel, or which is the before & which is the after of some cost or other value change. These new fields can also be calculated from other new fields that you defined earlier. Any of the selected fields can be totalled, sorted on, etc. In the column sizing you can make a field zero wide if you want to sort on it but not print it. However if you select on a calculated field in which divide by zero is possible, even if you also select on the divide by field to exclude the zeros, the query will bomb ... in those cases I add some tiny fraction to the divide by for safety. If you have a calculated field like a percentage & you try to average it ... at total time you do not get average percentage for all the data but average of adding up the percentage column & dividing by the number of lines, which might not be considered by some people to be a true percentage & in fact certainly not agree with percentages I do in RPG where I calculate total line from data on total line. I use query output to intermediate work files for several reasons. 1. I want to do calculations based on the totals of columns. 2. When combining multiple files, sometimes I get extra lines on reports. 3. This is an easier way to combine sub-sets of the same file. Recently I was lurking on Yahoo AS/400 clubs & posted some replies to Query/400 questions at http://clubs.yahoo.com/clubs/as400support ... you might find some additional insight there. MacWheel99@aol.com (Alister Wm Macintyre) (Al Mac)
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.