Conditions for Aggregate Function Values
The clause HAVING <Filter criterion> allows you to apply conditions to aggregate function values.
For the SELECT construction in the selection list you can define aggregate functions in the logical expression. You cannot indicate aggregate functions in other query language constructions conditions, for example in the clause WHERE.
Example:
// Selecting goods more than 20 pieces of which have been sold.
SELECT
Invoice.Nomenclature,
SUM (Invoice.Count) AS CountFROM
Document.ExpInvoice.Content AS InvoiceGROUP BY
Invoice.NomenclatureHAVING
SUM (Invoice.Count) > 20
Query result:
Nomenclature
Count
"Cowboy" shirt 30
Women's jeans 43
"Aquarium" bathroom 27
Important!You can only use aggregate functions and fields by which groups are implemented in filter criteria.