Looking for sql Answers? Try Ask4KnowledgeBase
Looking for sql Keywords? Try Ask4Keywords

SQL功能(聚合)


句法

  • 函数([ DISTINCT ]表达式)-DISTINCT是可选参数
  • AVG([ALL | DISTINCT]表达式)
  • COUNT({[ALL | DISTINCT]表达式] | *})
  • GROUPING(<column_expression>)
  • MAX([ALL | DISTINCT]表达式)
  • MIN([ALL | DISTINCT]表达式)
  • SUM([ALL | DISTINCT]表达式)
  • VAR([ALL | DISTINCT]表达式)
    OVER([partition_by_clause] order_by_clause)
  • VARP([ALL | DISTINCT]表达式)
    OVER([partition_by_clause] order_by_clause
  • STDEV([ALL | DISTINCT]表达式)
    OVER([partition_by_clause] order_by_clause)
  • STDEVP([ALL | DISTINCT]表达式)
    OVER([partition_by_clause] order_by_clause)

备注

在数据库管理中,聚合函数是一种函数,其中多行的值被组合在一起作为某些标准的输入,以形成更重要的含义或测量的单个值,例如集合,包或列表。

MIN        returns the smallest value in a given column
MAX        returns the largest value in a given column
SUM        returns the sum of the numeric values in a given column
AVG        returns the average value of a given column
COUNT      returns the total number of values in a given column
COUNT(*)   returns the number of rows in a table
GROUPING   Is a column or an expression that contains a column in a GROUP BY clause.
STDEV      returns the statistical standard deviation of all values in the specified expression.
STDEVP     returns the statistical standard deviation for the population for all values in the specified expression.
VAR        returns the statistical variance of all values in the specified expression. may be followed by the OVER clause.
VARP       returns the statistical variance for the population for all values in the specified expression.

聚合函数用于根据SELECT语句中的“返回的数值数据列”进行计算。它们基本上总结了特定选定数据列的结果。 - SQLCourse2.com

所有聚合函数都忽略NULL值。

功能(聚合) 相关例子