Previous Topic: Use Multiple FunctionsNext Topic: Add SUMMARIZE EACH Entity Action


Use Expressions as Functions

Aggregate functions other than Count Occurrences, Count Distinct, Sum Distinct, and Average Distinct use expressions as arguments provided that they meet the following restrictions:

Aggregate functions not be used as part of a larger expression.

Note: CURRENT views allowed in an aggregate function expression must be populated before the SUMMARIZE statement executes.

Single Entity View

To find the latest start time for all classes expressed in daylight standard time, use a statement similar to the following example:

SUMMARIZE class 
PLACING maximum(class start_time 
+ local_daylight_time adjustment_hours) 
INTO local_avg class start_time 
Multiple Entity Views

Use a statement similar to the following example to find the total billable amount (quantity times price plus sales tax):

SUMMARIZE order_line 
product 
PLACING sum((order_line qty_ordered * product unit_price) 
* (1 + CURRENT purchase_order sales_tax_rate)) 
INTO local purchase_order amt_billed 
WHERE DESIRED order_line belongs_to CURRENT purchase_order 
AND DESIRED product is_ordered_in DESIRED order_line 

Note: Both the entity views in the read list (order_line and product) are used as the subject of the aggregate function sum.