Data aggregation in MariaDB is performed using SQL GROUP BY statement and is used in conjunction with aggregate functions such as COUNT, MAX, MIN, AVG, and SUM to group the result-set by one or more columns.
Here are the basic steps to follow when performing data aggregation:
1. Select the table: First, you need to select the table where you want to perform data aggregation.
1. Use aggregate functions: After that, use the appropriate aggregate function i.e., COUNT, MAX, MIN, AVG, or SUM. These are the functions to perform operations on your data.
1. Use GROUP BY: Then use the GROUP BY statement. It groups the result-set by one or more columns.
1. Use WHERE: Finally, use the WHERE clause to filter your records when needed.
Here is an example of the syntax:
```
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;
```
For example, if you have a table named ‘orders’ and you want to know the total quantity of each product sold, you could use the following SQL statement:
```
SELECT product, SUM
FROM orders
GROUP BY product;
```
In this SQL query, the GROUP BY statement groups the “orders” table by the “product” column. The SUM function then calculates the sum of the “quantity” column for each group.