Re: GROUP SUM with WHERE in REPORT
Posted in 1996
John Prideaux <alastl@ix.netcom.com> wrote: :For this example, assume that all variables are declared correctly :and sensibly and that this code exists in an AFTER GROUP clause of :a report. I have verified that at the point in time where the :GROUP SUM is executed that curr_year = 1995 and that rows with :rpt.data_year = 1995 have been passed to the report. :for i = 1 to num_years : let curr_year = year_array[i] : let rpt.sub_line_year = curr_year : let turn_rec.begin_tons = (group sum(rpt.begin_tons) : where (rpt.data_year = curr_year)) :.... :end for :This code places a null into turn_rec.begin_tons. :If I replace the last line with : where (rpt.data_year = 1995) :I get correct output. :Is this a bug or a feature? I can restructure my report to get :the behavior I need, but I am curious. Have you thought of what the runtime code would have to do to actually calculate this group sum. Remember that the group sum has to be calculated by adding up data as each row is read. It would therefor have to know all possible values of curr_year and sum for each of those and then find these sums when your for loop is finaly executed. In my opinion the behaviour you see is a feature. Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org