Aggregates Examples

Aggregates Example Image

Experience the power of aggregations with our stunning examples.

Explore Now

Example 1: Basic Aggregation

This example demonstrates the core concept of aggregation: grouping data based on a key.

Data: Let's say we have a table with 'OrderDate', 'CustomerID', and 'TotalAmount'."

  1. Grouping: By 'OrderDate'
  2. Aggregation: Calculate the total amount per order.
  3. Output: TotalAmount

Example 2: Aggregating with a Date Range

Now let’s aggregate data within a specific timeframe.

Data: 'OrderDate' and 'CustomerID' data.

  1. Grouping: By 'OrderDate'
  2. Aggregation: Calculate the sum of 'TotalAmount' for each order date.
  3. Output: SumOfTotalAmount

Example 3: Aggregating with Multiple Keys

We can aggregate multiple columns.

Data: 'OrderDate', 'CustomerID', and 'ProductCategory' column.

  1. Grouping: By 'OrderDate'
  2. Aggregation: Calculate the total 'TotalAmount' per customer and product combination.
  3. Output: TotalAmountByCustomerProduct

Example 4: Aggregating with Customer

Aggregate by Customer. Lets say a 'Customer' column, 'CustomerID' and 'OrderDate'.

  1. Grouping: By 'Customer'
  2. Aggregation: Calculate the total order amount for each customer.
  3. Output: TotalOrderAmount