Re: Urgent help. SUM/TOTAL/PERCENT & variables. What a mouth full.
Posted in 1993
>From: rjc@cbnewsf.cb.att.com (robert.cook) >Subject: Urgent help. SUM/TOTAL/PERCENT & variables. What a mouth full. >Date: Mon, 13 Dec 1993 06:59:46 GMT >X-Informix-List-Id: <news.5074> >... >I'm doing a query and one field is "priority", a number. I need to get the >total count for the grouping (I'll use count(*), I presume). Then I need to >determine what percentage of the total were priority 1's for that grouping. >At the end of the report I need to give a total for ALL groupings. This >similar requirement is the same for other fields. >The trouble is I don't know how to to write it. Would you do like >to create a temp. variable for pri = "1" then do like >percent (count(*) / variable(value)). I don't know if that is necessary, but >I can't locate information on assigning & using temp variables. I guess you are using ACE, not I4GL. The information you are seeking is not documented because it isn't the way it's done. I think that what you need is probably: PRINT "Priority 1 calls = ", ((GROUP COUNT(*) WHERE pri = "1") / (GROUP COUNT(*))) * 100 USING "##&.&&", "% of total for ", group_designator Comments: 1. Use brackets liberally to get the required result. Do not take chances. 2. Be wary of group percent -- it probably doesn't compute the value you're looking for. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>