Page History
Table of Contents minLevel 2 type flat
AVERAGE
Use this function to determine the average (arithmetic mean) of a list or collection.
The AVG function has two syntax forms: the collection form and the list form. You can use the collection form to determine the average value of all occurrences of an attribute. The list form is used to determine the average value of a set of different attributes.
Collection form syntax
Code Block |
---|
AVG(attribute) |
- attribute - An attribute of any type of number or date of which multiple instances can occur at runtime.
List form syntax
Code Block |
---|
AVG([value1, value2, ...]) |
- [value1, value2, …] - A list of attributes, expressions or fixed values of any type of number or date. Use the square brackets to indicate that the arguments form a list of values.
Return types
- number
- integer
- currency
- percentage
- date
The function returns UNKNOWN if one or more values are UNKNOWN.
Examples
Suppose the following domain model.
Entity.attribute | Multivalued relation | Entity.attribute |
---|---|---|
Residence.appraisalValue Residence.askingPrice Residence.mortgage | hasBiddings | Bidding.amount |
If you want to determine the average bidding on the current residence:
- AVG(Residence.hasBiddings.amount)
If you want to determine the average amount of the appraisal value, the asking price and the mortgage of the current residence:
- AVG([Residence.appraisalValue, Residence.askingPrice, Residence.mortgage])
MIN
Use this function to determine the minimum value of a list or collection.
The MIN function has two syntax forms: the collection form and the list form. You can use the collection form to determine the minimum value of all occurrences of an attribute. The list form is used to determine the minimum value of a set of different attributes.
Collection form syntax
Code Block |
---|
MIN(attribute) |
- attribute - An attribute of any type of number or date of which multiple instances can occur at runtime.
List form syntax
Code Block |
---|
MIN([value1, value2, ...]) |
- [value 1, value 2, …] - A list of attributes, expressions or fixed values of any type of number or date. Use the square brackets to indicate that the arguments form a list of values.
Examples
Suppose the following domain model.
Entity.attribute | Multivalued relation | Entity.attribute |
---|---|---|
Residence.appraisalValue Residence.askingPrice Residence.mortgage | hasBiddings | Bidding.amount |
If you want to determine the lowest bidding on the current residence:
- MIN(Residence.hasBiddings.amount)
If you want to determine the smallest amount within the appraisal value, the asking price and the mortgage:
- MIN([Residence.appraisalValue, Residence.askingPrice, Residence.mortgage])
MAX
Use this function to determine the maximum value of a list or collection.
The MAX function has two syntax forms: the collection form and the list form. You can use the collection form to determine the maximum value of all occurrences of an attribute. The list form is used to determine the maximum value of a set of different attributes.
Collection form syntax
Code Block |
---|
MAX(attribute) |
- attribute - An attribute of any type of number or date of which multiple instances can occur at runtime.
List form syntax
Code Block |
---|
MAX([value1, value2, ...]) |
- [value 1, value 2, …] - A list of attributes, expressions or fixed values of any type of number or date. Use the square brackets to indicate that the arguments form a list of values.
Examples
Suppose the following domain model.
Entity.attribute | Multivalued relation | Entity.attribute |
---|---|---|
Residence.appraisalValue Residence.askingPrice Residence.mortgage | hasBiddings | Bidding.amount |
If you want to determine the highest bidding on the current residence:
- MAX(Residence.hasBiddings.amount)
If you want to determine the highest amount within the appraisal value, the asking price and the mortgage:
- MAX([Residence.appraisalValue, Residence.askingPrice, Residence.mortgage])
COUNT
Use this function to retrieve the number of instances for the specified entities or attributes.
Syntax
Code Block |
---|
COUNT(collection) |
- collection - A collection of attribute or entity instances.
Return type
- integer
Examples
Suppose the following data model.
Instance | Person.name |
---|---|
1 | “John” |
2 | “Dave” |
3 | “Jane” |
4 | “Lisa” |
Instance | House.rooms |
---|---|
singleton | “living room”, “bathroom”, “bedroom” |
- COUNT(ALL Person) results in 4
- COUNT(House.rooms) results in 3
- COUNT(ALL Person + ALL House) results in 5
- COUNT(COLLECT Person FROM ALL Person WHERE(Person.name = “Lisa”)) results in 1
- COUNT(? (= UNKNOWN)) results in UNKNOWN
Note |
---|
SIZE and COUNT are similar except for ?: SIZE(?) = 0 |