SQL Server中SQL COUNT和COUNT

您所在的位置:网站首页 sql中聚合函数是什么意思 SQL Server中SQL COUNT和COUNT

SQL Server中SQL COUNT和COUNT

2024-03-16 09:59| 来源: 网络整理| 查看: 265

In this article, we’ll walk-though two other important SQL aggregate function, SQL COUNT and COUNT_BIG. In the previous article of this series, we covered how to retrieve data, join tables, work with dates and times, use window functions, filter data, and much more.

在本文中,我们将介绍另外两个重要SQL聚合函数SQL COUNT和COUNT_BIG。 在本系列的上一篇文章中,我们介绍了如何检索数据,联接表,使用日期和时间,使用窗口函数,过滤数据等等。

This article addresses the following commonly asked questions:

本文解决以下常见问题:

What are aggregate functions in SQL Server?

SQL Server中的聚合函数是什么? What are the roles of aggregate functions in SQL?

聚合函数在SQL中的作用是什么? Why and how is the group by clause used with aggregate functions?

为什么group by子句以及如何与聚合函数一起使用? How are aggregate functions used in a where clause?

在where子句中如何使用聚合函数? 介绍 (Introduction)

Aggregate functions are also a type of calculation; the calculations are defined on a set of values and return a single value. An aggregate calculation summarizes values from entire groups of rows. Except for the SQL COUNT function, aggregate functions ignore null values.

集合函数也是一种计算方式。 计算是根据一组值定义的,并返回一个值。 汇总计算汇总了整个行组中的值。 除SQL COUNT函数外,聚合函数将忽略空值。

Aggregate functions are widely used with the GROUP BY clause in the SELECT statement. All aggregates are deterministic functions. In short, it returns the same value each time when it is operated with a specific set of the input values.

聚合函数广泛用于SELECT语句中的GROUP BY子句。 所有集合都是确定性函数。 简而言之,每次使用一组特定的输入值进行操作时,它都会返回相同的值。

The basic SQL aggregated functions are:

基本SQL聚合函数为:

SUM

Calculate totals of a given specified field

AVG

Calculate averages of a specified field

COUNT/COUNT_BIG

Count the number of records

MIN

Get the minimum value of a specified field

MAX

Get the maximum value of a specified field

计算给定指定字段的总数

AVG

计算指定字段的平均值

COUNT / COUNT_BIG

计算记录数

最低

获取指定字段的最小值

最大值

获取指定字段的最大值

In this article, we will take a look at the SQL COUNT and SQL COUNT_BIG aggregate functions. Both functions operate in a similar way but it differs only in the return type. The aggregate function, COUNT, always returns an integer but whereas COUNT_BIG returns type is a bigint data type.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3