How To Create an Aggregation

Situation

You need to retrieve a total (SUM, COUNT, AVG) from the database. An equivalent to

SELECT SUM(Price) FROM SalesOrder GROUP BY refBusinessPartnerId
  1. Add Data Structure Field

Go to the data structure where there should be an aggregated field. Right click on the datastructure entity and select New > Field.

  1. Select an Aggregation

In the properties of this new field select the Field property and set the Aggregation. Possibilities are:

  • Count
  • Sum
  • Average
  • Maximum
  • Minimum
  • CumulativeSum (this can only be used for specifying an aggregation type for charts, not for SQL aggregation).

This will produce the aggregation SQL. All fields that have no aggregation specified will be included in the GROUP BY clause.