SQL Aggregate Functions and Group Statistics

Aggregate function

1. The SUM function sums all values.

2. The AVG function returns the average value of a numeric column,

Where the data column NULL is not included in the calculation.

3. The MAX function returns the maximum value in a column,

The MIN function returns the minimum value in a column,

Where the data column NULL is not included in the calculation.

4. The COUNT function returns the number of non-empty rows in the result set

Group Statistics Syntax

SELECT field list [aggregate function]

FROM table name

[WHERE condition]

[GROUP BY<field list>]

[HAVING CONDITIONS]

[ORDER BY field list ASC/DESC]

The field list after SELECT must be consistent with the field list after GROUP BY.

The difference between HAVING and WHERE is that WHERE can only filter the data before grouping statistics, and HAVING must be used to filter the data after grouping

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326036071&siteId=291194637