Aggregate values (sums, etc)

From: Peter Ritter <[email protected]> - 18 Jan 1999

 > how can I get a view which contains the SUM for each type:
 >
 > Apples       13
 > Oranges      23

You can use GroupBy to greate a view which has one row per FruitType, and a (virtual, i.e. faked) subview listing all the matching entries. Then, because such views are not updatable, you'll have to make a copy. Finally, run through each of the subviews and aggregate the sums (there is no ready-made version, but then this is just a simple and fast loop).

But you might get the same result probably just as easily with:

         - sort on FruitType (GroupBy does sorting internally, too)
         - create a new results view
         - run through each row, add new entry to results when the
           FruitType is not the same as the previous row
         - accumulate the count in the last row of the results view
 > [...] If so, is there a way to calculate AVERAGE, and MIN, MAX etc?

No, what you see in Metakit 1.8.5 is just the start of basic relational functionality. I hope to have shown that the necessary sorts/loops are relatively easy to implement on a case-by-case basis.

-- JC