zhiqingstudy

Be a young person with knowledge and content

1. Introduction to aggregate function

Aggregation function is also called group function, which usually counts and calculates the data in the table. It is generally used in combination with group by for statistics and calculation of group data.

Common aggregate functions:

① , count (col): calculate the total number of rows of the specified column

② , Max (col): to calculate the maximum value of the specified column

③ , Min (col): to find the minimum value of the specified column

④ Sum (col): sum the specified column

⑤ , Avg (col): calculate the average value of the specified column

2. Query the number of students

Syntax: SELECT COUNT (` id ') FROM ` students';

Note: The aggregate function does not count null values. Generally, if you want to specify a column name, it is a primary key field.

General writing method: SELECT COUNT (*) FROM ` students';

3. Query the oldest student of a girl

语法:SELECT MAX(age) FROM `students` WHERE `gender` = ‘女’;

4. Query the average height of male students

语法:SELECT avg( `height`) FROM `students` WHERE `gender` = ‘男’;

comment
head sculpture
Code:
Related

Why you shouldn't stay at a job for more than 2 years?

3 harsh facts long-distance relationships

how to keep your girlfriend interested in a long-distance relationship




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号