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 Count

FROM
   Document.ExpInvoice.Content AS Invoice

GROUP BY
   Invoice.Nomenclature

HAVING
   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.

1C:Enterprise Developer's Community