# Non-basic Aggregation Examples

## 1. SUM aggregate after enumeration grouping

【Example 1】 Based on the GDP table, calculate the GDP per capita for direct-controlled municipalities, first-tier cities and second-tier cities respectively. Below is part of the source table:

【SPL script】

A5’s result:

## 2. Merge overlapping time intervals

【Example 2】 The following is part of the orders table. We want to merge records of customer ANATR that have overlapping time periods (between order date and finish date).

【SPL script】

A4’s result:

## 3. Grouping & conditional COUNT aggregate

【Example 4】 The following is part of the scores table. We want to, for each subject, find the number of students in class one who fail in this subject.

【SPL script】

A3’s result:

## 4. Perform logical AND on a set of Boolean values

【Example 5】 Based on the following primary school online-learning terminal tables (as shown by pic 2), we want to find if all students use mobile phones to learn. Pic 1 is the directory where the tables for classes of all grades are stored.

【SPL script】

A4’s result:

## 5. Perform logical OR on a set of Boolean values

【Example 6】 The following is part of the sales data. We want to find if there is at least one month in 2014 when customer RATTC’s amount ranks in top 3.

【SPL script】

A7’s result:

Find more examples in SPL CookBook.