Get the App
SLTechnology News&Howtos  ›  Database  › 

A brief Analysis of five aggregate functions of MySQL

Shulou Source: shulou.com Published: 2022-06-01 20:11:14 10月02日 Update

This article mainly gives you a brief introduction to the five aggregate functions of MySQL. You can look up the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here. Let's go straight to the topic of brief analysis of the five aggregate functions of MySQL. I hope we can bring you some practical help.

In order to get statistics quickly, five aggregate functions are provided.

* count () indicates that the total number of rows is calculated, and the star and column names are written in parentheses. The result is the same * *

Inquire about the total number of students

Select count (*) from students

Max (column) means to find the maximum value of this column

Query the maximum number of girls

Select max (id) from students where gender=0

Min (column) means to find the minimum value of this column

Query the minimum number of undeleted students

Select min (id) from students where isdelete=0

Subquery

Select * from students where id= (select min (id) from students where isdelete=0)

Sum (column) represents the sum of this column

After querying the boy's number

Select sum (id) from students where gender=1

Avg (column) means to find the average of this column.

Query the average number of undeleted girls

Select avg (id) from students where isdelete=0 and gender=0

This is the end of the brief analysis of the five aggregate functions of MySQL. If you want to know about other related issues, you can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

Tags: Query function this column maximum minimum major female student average maximum industry same expertise subject book content actual total head line parenthesis Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple MariaDB Docker MySQL