Specifics of using the GROUP BY clause





1C:Enterprise query language offers the GROUP BY clause for grouping (collapsing) records by specific fields. This clause is similar to the GROUP BY clause of the SQL standard but does have a few peculiarities.

The major peculiarity is that when the GROUP BY clause contains a field, all the fields received from it using . (dot) are also considered grouped. Example:

SELECT 
	CustomerOrder.Counterparty, 
	CustomerOrder.Counterparty.Code, 
	CustomerOrder.Counterparty.Description, 
	SUM(CustomerOrder.DocumentTotal) AS DocumentTotal 
FROM 
	Document.CustomerOrder AS CustomerOrder
GROUP BY 
	CustomerOrder.Counterparty

In this example automatic grouping by the CustomerOrder.Counterparty.Code and CustomerOrder.Counterparty.Description fields will be performed because the GROUP BY clause contains the CustomerOrder.Counterparty field with its data received using . (dot).


Comments
0
Add comment