Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the aggregate function in SQL Server

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Xiaobian to share with you what is the aggregation function in SQL Server, I hope you have something to gain after reading this article, let's discuss it together!

Aggregate functions in SQL Server are: 1, AVG;2, COUNT;3, MAX;4, SUM;5, COUNT_BIG;6, MIN;7, GROUPING;8, VAR;9, STDEV;10, VARP.

Aggregate functions in SQL Server include:

AVG returns the average value in the specified group, null values are ignored.

For example:

select prd_no,avg(qty) from sales group by prd_no

COUNT Returns the number of items in the specified group.

For example:

select count(prd_no) from sales

MAX Returns the maximum value of the specified data.

For example:

select prd_no,max(qty) from sales group by prd_no

MIN Returns the minimum value of the specified data.

For example:

select prd_no,min(qty) from sales group by prd_no

SUM returns the sum of the specified data, which can only be used for numeric columns, and null values are ignored.

For example:

select prd_no,sum(qty) from sales group by prd_no

COUNT_BIG returns the number of items in the specified group, unlike COUNT, which returns a bigint value.

For example:

select count_big(prd_no) from sales

GROUPING produces an additional column, the output value is 1 when the row is added with CUBE or ROLLUP operator. The output value is 0 when the added row is not produced by CUBE or ROLLUP.

For example:

select prd_no,sum(qty),grouping(prd_no) from sales group by prd_no with rollup

BINARY_CHECKSUM Returns a binary check value computed on a row or list of expressions in a table to detect changes to rows in the table.

For example:

select prd_no,binary_checksum(qty) from sales group by prd_no

CHECKSUM_AGG returns the check value of the specified data, null values are ignored.

For example:

select prd_no,checksum_agg(binary_checksum(*)) from sales group by prd_n

CHECKSUM returns a check value computed on a row of a table or on a list of expressions used to generate a hash index.

STDEV returns the statistical standard deviation of all values in a given expression.

select stdev(prd_no) from sales

STDEVP returns the fill statistical standard deviation of all values in a given expression.

For example:

select stdevp(prd_no) from sales

VAR returns the statistical variance of all values in a given expression.

For example:

select var(prd_no) from sales

VARP returns the statistical variance of the population of all values in a given expression.

For example:

select varp(prd_no) from sales After reading this article, I believe you have a certain understanding of "What is the aggregation function in SQL Server". If you want to know more about it, welcome to pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report