Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

What is difference between aggregate functions: count and cumulative count?

The count is well known and is simple to explain. Count function counts a number of items/records that satisfy the given criteria.

The cumulative count function is the sum of all the counts generated so far. Mathematically it is represented as

Sk = ∑Ci for i = 1 to k

When k = 3, i.e., 3rd cumulative count is calculated by adding up the first 3 counts C1, C2, C3

This might seem not very clear. So let's clear the air with an example:

Consider the following table:

DateCount
 
5
 
7
 
2

 

3
 
4

The above table is generated by using a simple count of specimens collected every day for the first 5 days of the month of Jan 2018. However, this table doesn't give an idea of how many specimens were collected in total until a given date. For this purpose, we need to use a cumulative count. The 3rd column in the below table is generated using the cumulative count function.

DateCountCumulative Count
 
55
 
712
 
214
 
317
 
421

The difference can be best visualized using below the graph.



Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com