invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

Aggregating

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 Sorting and Filtering Rows.

An Example

Over the sample database:

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: The "Results" panel of Invantive Query Tool showing five municipalities with a "Number of Rows" column from an aggregate.

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 Connection Monitor as bytes received, and in the 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 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 Group Functions and Grouping.

Release Notes