Aggregate Functions of Query Language
Query language provides aggregate functions used when grouping query results and calculating totals.
You can use aggregate functions to summarize values of a given parameter.
The following aggregate functions are defined:
<Aggregate function> | |||
| | |||
SUM ( <Expression> ) | AVERAGE (<Expression> ) | MINIMUM (<Expression> ) | MAXIMUM (<Expression> ) | QUANTITY ( [VARIOUS] <Expression> | * ) |
Example:
SELECT
Invoice.Nomenclature.Name,
SUM (Invoice.Sum) AS Sum,
AVERAGE (Invoice.Sum) AS Average,
MAXIMUM (Invoice.Sum) AS Maximum,
MINIMUM (Invoice.Sum) AS Minimum,
QUANTITY (Invoice.Quantity) AS QuantityFROM
Document.ExpInvoice.Content AS InvoiceGROUP BY
Invoice.NomenclatureGRAND TOTALS
Query result:
Name
Sum
Average
Maximum
Minimum
Quantity
265 955,45
12 511,12
40 000,23
555
8
Children's pants
28 500,22
9 500,07
15 000
3 000
3
"Cowboy" shirt
24 000
8 000
16 000
4 000
3
Women's jeans
63 555
6 355,5
30 000
555
10
Children's sweater
6 400
6 400
6 400
6 400
1
"Lilia" sink
60 000,23
30 000,115
40 000,23
20 000
2
"Aquarium" bathroom
65 500
21 833,33
40 000
8 000
3
"Ultra" mixer
15 000
15 000
15 000
15 000
1
Krups food processor
3 000
3 000
3 000
3 000
1
You can use aggregate functions in the selection fields list, in the HAVING, TOTALS, ORDER BY clauses.
See also:
SUM function
AVERAGE function
MINIMUM function
MAXIMUM function
QUANTITY function