Dino Geek, try to help you

How to use aggregate functions in MariaDB?


Aggregate functions in MariaDB are used to perform calculations on multiple rows of a single column of a table and return a single value. They come handy when small pieces of information, such as the total amount or average amount, need to be quickly extracted from a large volume of data.

Here are some commonly used aggregate functions:

- `COUNT`: Returns the total number of rows that match a specified criteria.
- `SUM`: Returns the combined sum of all rows that match a specified criteria.
- `AVG`: Returns the average value of a numeric column.
- `MIN`: Returns the smallest value of the selected column.
- `MAX`: Returns the largest value of the selected column.

Here is how they can be used:

1. `COUNT` function:
```
SELECT COUNT
FROM table_name;
```
The COUNT function returns the total number of rows in the table.

1. `SUM` function:

```
SELECT SUM
FROM table_name;
```
The SUM function returns the total sum of all values in the specified column.

1. `AVG` function:

```
SELECT AVG
FROM table_name;
```
The AVG function returns the average value of a numeric column.

1. `MIN` function:

```
SELECT MIN
FROM table_name;
```
The MIN function returns the smallest value of the selected column.

1. `MAX` function:

```
SELECT MAX
FROM table_name;
```
The MAX function returns the largest value of the selected column.

You may also combine aggregate functions with the `GROUP BY` statement to retrieve information about a group of rows:

```
SELECT COUNT, column2_name
FROM table_name
GROUP BY column2_name;
```
In this query, MariaDB counts the number of rows for each distinct value in column2\_name.

Remember to replace “table_name” and “column_name” with your actual table and column names.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use