SQL Server MAX()聚合函数

SQL Server provides us with several aggregate functions that can be used to perform different types of calculations on a set of values, and return a single value that summarized the input d...
摘要由CSDN通过智能技术生成

SQL Server provides us with several aggregate functions that can be used to perform different types of calculations on a set of values, and return a single value that summarized the input data set. These SQL Server aggregate functions include AVG(), COUNT(), SUM(), MIN() and MAX().

SQL Server为我们提供了几个聚合函数,这些函数可用于对一组值执行不同类型的计算,并返回汇总输入数据集的单个值。 这些SQL Server聚合函数包括AVG(),COUNT(),SUM(),MIN()和MAX()。

In this article, we will go through the MAX() aggregate function usage and provide multiple examples of the MAX() function usage.

在本文中,我们将介绍MAX()聚合函数的用法,并提供MAX()函数用法的多个示例。

用法 (Usage)

SQL MAX() aggregate function is used to return the maximum value from the provided numerical expression or the highest value in the collating sequence from the provided character expression.

SQL MAX()聚合函数用于从提供的数字表达式返回最大值,或者从提供的字符表达式返回整理序列中的最大值。

句法 (Syntax)

The T-SQL syntax for the MAX() aggregate function is like:

MAX()聚合函数的T-SQL语法如下:

MAX( [ ALL | DISTINCT ] expression )

Where the ALL option, which is the default option, indicates that the MAX() aggregate function will be applied to all the expression values and the DISTINCT option indicates that each unique value will be considered in the aggregate function, which is not applicable for the MAX() function.

其中ALL选项(默认选项)指示MAX()聚合函数将应用于所有表达式值,而DISTINCT选项指示将在聚合函数中考虑每个唯一值,不适用于MAX()函数。

The Expression here can be passed to the MAX() aggregate function can be any numeric, character, uniqueidentifier or DateTime table column, considering that the BIT data type cannot be used with the MAX() aggregate function.

考虑到BIT数据类型不能与MAX()聚合函数一起使用,此处的表达式可以传递给MAX()聚合函数,可以是任何数字,字符,uniqueidentifier或DateTime表列。

The MAX() aggregate function can also take a constant value or any arithmetic or string expression, taking into consideration that the MAX() aggregate function will ignore any NULL value in the input expression.

考虑到MAX()聚合函数将忽略输入表达式中的任何NULL值,MAX()聚合函数也可以采用常量值或任何算术或字符串表达式。

The value that is returned from the SQL MAX() aggregate function will be the same as the Expression data type, and the returned value will be NULL when the input expression has no rows to read from.

从SQL MAX()聚合函数返回的值将与Expression数据类型相同,并且当输入表达式没有要读取的行时,返回值将为NULL。

SQL MAX()聚合函数的示例 (Examples of SQL MAX() aggregate function)

For the SQL MAX() aggregate function demo purposes, let us create a new testing table th

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值