Counting, adding up and averaging is written as a `group by` in the statement, and the engine has the platform do the work where the platform can. That is the difference with the summaries of the grid, which count what has already arrived; see [[Invantive Query Tool/Sorting and Filtering Rows|Sorting and Filtering Rows]]. ## An Example Over the [[Invantive Query Tool/Sample Database|sample database]]: ```sql select pjt_gemeente , count(*) aantal , min(pjt_code) eerste from Projects@dummy group by pjt_gemeente order by aantal desc ``` Five municipalities, six projects in the largest: ![[20260904-qt-aggregate.png]] The heading of a counted column reads "Number of Rows" rather than the alias: a column which the engine recognises is labelled with what it means, and an alias of its own is shown as written. Which label a column carries is decided by the metadata, not by the grid. ## Where the Work Happens An aggregate over a database - Microsoft SQL Server, Oracle, PostgreSQL, MySQL - is pushed down: the platform counts and returns the answer. Over a cloud platform which cannot count on its own the engine reads the rows and counts them itself, and the traffic is then the whole table rather than the answer. Which of the two happened is visible in the [[Invantive Query Tool/Connection Monitor|Connection Monitor]] as bytes received, and in the [[Invantive Query Tool/Progress|Progress]] panel as the rows which passed the step. That is worth knowing before an aggregate over a large cloud table is repeated every morning: the [[Invantive Query Tool/Data Cache|data cache]] exists for exactly that case. ## The Functions The group functions - `count`, `sum`, `min`, `max`, `avg`, `stddev` and the rest - and what may stand in a `having` are documented under [[Invantive UniversalSQL/General/Group Functions|Group Functions]] and [[Invantive UniversalSQL/General/Grouping|Grouping]].