Save 
Join IIUG
 for   
 

Informix News
13 Jan 12 - MC Press online - Informix Dynamic Server Entices New Users with Free Production Edition ... Read
11 Jan 12 - Computerworld - Ecologic Analytics and Landis+Gyr -- Suitors Decide to Tie the Knot... Read
9 Jan 12 - planetIDS.com - DNS impact on Informix / Impacto do DNS no Informix... Read
8 Sep 11 - TMCnet.com - IBM Offers Database Solution to Enable Smart Meter Data Capture... Read
1 Aug 11 - IBM Data Management Magazine - IIUG user view: Happy 10th anniversary to IBM and Informix... Read
8 Jul 11 - Database Trends and Applications - Managing Time Series Data with Informix... Read
31 May 11 - Smart Grid - The meter data management pitfall utilities are overlooking... Read
27 May 11 - IBM Data Management Magazine - IIUG user view: Big data, big time ( Series data, warehouse acceleration, and 4GLs )... Read
16 May 11 - Business Wire - HiT Software Announces DBMoto for Enterprise Integration, Adds Informix. Log-based Change Data Capture... Read
21 Mar 11 - Yahoo! Finance - IBM and Cable&Wireless Worldwide Announce UK Smart Energy Cloud... Read
14 Mar 11 - MarketWatch - Fuzzy Logix and IBM Unveil In-Database Analytics for IBM Informix... Read
11 Mar 11 - InvestorPlace - It's Time to Give IBM Props: How many tech stocks are up 53% since the dot-com boom?... Read
9 Mar 11 - DBTA - Database Administration and the Goal of Diminishing Downtime... Read
2 Feb 11 - DBTAs - Informix 11.7 Flexible Grid Provides a Different Way of Looking at Database Servers... Read
27 Jan 11 - exactsolutions - Exact to Add Informix Support to Database Replay, SQL Monitoring Solutions... Read
25 Jan 11 - PR Newswire - Bank of China in the UK Works With IBM to Become a Smarter, Greener Bank... Read
12 Oct 10 - Database Trends and Applications - Informix 11.7: The Beginning of the Next Decade of IBM Informix... Read
20 Sep 10 - planetIDS.com - ITG analyst paper: Cost/Benefit case for IBM Informix as compared to Microsoft SQL Server... Read
20 Jul 10 - IBM Announcements - IBM Informix Choice Edition V11.50 helps deploy low-cost scalable and reliable solutions for Apple Macintosh and Microsoft Windows... Read
20 Jul 10 - IBM Announcements - Software withdrawal: Elite Support for Informix Ultimate-C Edition... Read
24 May 10 - eWeek Europe - IBM Supplies Database Tech For EU Smart Grid... Read
23 May 10 - SiliconIndia - IBM's smart metering system allows wise use of energy... Read
21 May 10 - CNET - IBM to help people monitor energy use... Read
20 May 10 - ebiz - IBM Teams With Hildebrand To Bring Smart Metering To Homes Across Britain... Read
19 May 10 - The New Blog Times - Misurare il consumo energetico: DEHEMS è pronto... Read
19 May 10 - ZDNet - IBM software in your home? Pact enables five-city smart meter pilot in Europe... Read
17 March 10 - ZDNet (blog) David Morgenstern - TCO: New research finds Macs in the enterprise easier, cheaper to manage than... Read
17 March 2010 - Virtualization Review - ...key components of Big Blue's platform to the commercial cloud such as its WebSphere suite of application ser vers and its DB2 and Informix databases... Read
10 February 2010 - The Wall Street Journal - International Business Machines is expanding an initiative to win over students and professors on its products. How do they lure the college crowd?... Read


End of Support Dates

IIUG on Facebook IIUG on Twitter


[ Post Response ] [ Return to Index ] [ Read Prev Msg ] [ Read Next Msg ]

Classics Forum

Re: RE: save aggregate as variable in report

Posted By:
Date:





I saw your THANKS message -- I was amused that it got the tag number 101.

It isn't clear to me what your computations are doing - why you are summing
some values and counting others, for example.

Be aware that your B.G.O clause is dealing with grand totals - over the
entire report data set - not per group totals. And note that the code
shown is syntactically incorrect -- see the inserted line I added.

What I think you might want to do is:

DEFINE
VARIABLE var DECIMAL
END

...big chunk omitted...

AFTER GROUP OF hist_coopcode
IF hist_coopcode = "lis" THEN
BEGIN
LET var = 3 * (GROUP TOTAL OF hist_sze WHERE hist_coopcode =
"lis")
PRINT "Coop Code: ", hist_coopcode, COLUMN 15, " = ", COLUMN
18, var USING "####.##"
END
ELSE IF hist_coopcode = "021" THEN
BEGIN
LET var = 6 * (GROUP COUNT WHERE hist_coopcode = "021")
PRINT "Coop Code: ", hist_coopcode, COLUMN 15, " = ", COLUMN
18, var USING "####.##"
END
...

And then your ON LAST ROW block might read:

ON LAST ROW
LET var = 3 * (TOTAL OF hist_sze WHERE hist_coopcode = "lis") +
6 * (COUNT WHERE hist_coopcode = "021") +
...
PRINT "Total sales:", COLUMN 18, var USING "###&.&&"

Note that the WHERE clauses in the A.G.O block are technically redundant
(when the hist_coopcode = "021", the GROUP COUNT is only for the case where
hist_coopcode = "021"), but they clarify the code in the ON LAST ROW block.
You could also print the expressions on the RHS of the LET statements
directly in the PRINT statements in the A.G.O block, but again, the code is
clearer as written. Indeed, the BEGIN and END can be removed because a
single PRINT in the A.G.O block would do the job:

AFTER GROUP OF hist_coopcode
IF hist_coopcode = "lis" THEN
LET var = 3 * (GROUP TOTAL OF hist_sze WHERE hist_coopcode =
"lis")
ELSE IF hist_coopcode = "021" THEN
LET var = 6 * (GROUP COUNT WHERE hist_coopcode = "021")
...

PRINT "Coop Code: ", hist_coopcode, COLUMN 15, " = ", COLUMN 18, var
USING "####.##"

This is perhaps the best reason for introducing the variable - it makes it
clear what's different (the computed value) and what's the same (the print
formatting).

Also, I'm highly dubious about those hard-wired 3 and 6 values; those
should be being retrieved from the database, so that the multiplication is
done between two selected values.

If it were not for the odd-ball case with TOTAL versus everything else with
COUNT, then you might be able to handle the ON LAST ROW clause with a
suitable TOTAL OF clause. This is a domain-specific issue -- only you know
what a coopcode is, and why the rules are as they are. Note that if you
need to add coopcode "039" at some point, you have to do major surgery on
the report.

--
Jonathan Leffler (jleffler@us.ibm.com)
STSM, Informix Database Engineering, IBM Data Management Solutions
4100 Bohannon Drive, Menlo Park, CA 94025
Tel: +1 650-926-6921 Tie-Line: 630-6921
"I don't suffer from insanity; I enjoy every minute of it!"


|---------+---------------------------->
| | "JAY ZWAGERMAN" |
| | <jay2@iafalls.com|
| | > |
| | Sent by: |
| | forum.subscriber@|
| | iiug.org |
| | |
| | |
| | 02/27/2003 09:31 |
| | AM |
| | |
|---------+---------------------------->
>---------------------------------------------------------------------------------------------------------------------------------------------|
| |
| To: classics@iiug.org |
| cc: |
| Subject: Re: RE: save aggregate as variable in report [92] |
| |
>---------------------------------------------------------------------------------------------------------------------------------------------|




Let me clarify my question and give my code. Here is the bottom part of my
ace report. In the before group of, you see that I use if else statements
to find 4 different totals. I can’t do a group total of in the “on last
row” and when I do ust a total of in "on last row" It doesn't give me a
total of the computed numbers.

format

page header
print column 30, "The Spokesman"
skip 1 line
print column 20, "Web Sales Total",1 space,userbdate," -
",useredate
skip 1 line
print column 25, "Coops: 001 - 017 - 021 - lis"

before group of hist_coopcode
if hist_coopcode = "lis" then
print "Coop Code: ",hist_coopcode,column 15," = ",column 18,
total of (hist_sze * 3.00) using "####.##"
else if hist_coopcode = "021" then
print "Coop Code: ",hist_coopcode,column 15," = ",column 18,
count * 6 using "####.##"
[...JL: there's a line missing here...probably 'else if hist_coopcode =
"017" then'...]
print "Coop Code: ",hist_coopcode,column 15," = ",column 18,
count * 3 using "####.##"
else if hist_coopcode = "001" then
print "Coop Code: ",hist_coopcode,column 15," = ",column 18,
count * 3 using "####.##"
on last row
print "Total sales:" SOMETHING


Here is the output so far

Input begin date (using MMDDYY):02012003




The Spokesman

Web Sales Total 02/01/2003 - 02/28/2003

Coops: 001 - 017 - 021 - lis
Coop Code: 001 = 372.00
Coop Code: 017 = 372.00
Coop Code: 021 = 744.00
Coop Code: lis = 247.50
Total sales:



Messages In This Thread

[ Post Response ] [ Return to Index ] [ Read Prev Msg ] [ Read Next Msg ]

Classics Forum is maintained by Administrator with WebBBS 5.12.