Home >Database >SQL >What are the commonly used aggregate functions in SQL?

What are the commonly used aggregate functions in SQL?

下次还敢
下次还敢Original
2024-05-07 05:54:161264browse

Aggregation functions in SQL are used to combine multiple values. Commonly used functions are: SUM() for summation, AVG() for average value, MIN() for minimum value, MAX() for maximum value, and COUNT. () finds the count, DISTINCT COUNT() finds the unique count, TOTAL() finds the sum within the partition, AVERAGE() finds the average within the partition, BIT_AND() finds the bitwise AND, BIT_OR() finds the bitwise OR, GREATEST() finds the maximum Value, LEAST() finds the minimum value.

What are the commonly used aggregate functions in SQL?

Aggregation Functions in SQL

Aggregation functions are used to combine multiple values ​​in a data set into a single value . Commonly used aggregate functions in SQL include:

1. Sum function: SUM()

  • Calculate the sum of all values ​​in the data set.

2. Average function: AVG()

  • Calculate the average of all values ​​in the data set.

3. Find the minimum value function: MIN()

  • Returns the minimum value in the data set.

4. Maximum function: MAX()

  • Returns the maximum value in the data set.

5. Find the counting function: COUNT()

  • Calculate the number of records in the data set.

6. Find the unique count function: DISTINCT COUNT()

  • Calculate the count of unique values ​​in the data set.

7. Total function: TOTAL()

  • Calculate the sum of all values ​​in a partition.

8. Average function: AVERAGE()

  • Calculate the average of all values ​​in a partition.

9. Function to find the sum of digits: BIT_AND()

  • Performs a bitwise AND operation on the numbers in the data set and returns the bitwise sum of the result .

10. Find the bitwise OR function: BIT_OR()

  • Perform a bitwise OR operation on the numbers in the data set and return the bitwise OR of the result .

11. Maximum function: GREATEST()

  • Returns the maximum of two or more values.

12. Minimum value function: LEAST()

  • Returns the minimum value of two or more values.

The above is the detailed content of What are the commonly used aggregate functions in SQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn