Upload
ronald-cobb
View
213
Download
1
Embed Size (px)
Citation preview
Who am I?
I have over 25 year experience IT. I have a vast array of abilities in the field in the areas of Network, Desktop Support, DBA, Staff Project Management, Application Software Development, Business Analysis and Quality Assurance. I have Microsoft certifications as MCTS, MCPS, and MCNPS, and multiple certifications from the Insurance Institute of America. Currently I am a DBA at Unitrin Direct Insurance.
Aggregate Functions
AVG MIN
CHECKSUM_AGG SUM
COUNT STDEV
COUNT_BIG STDEVP
GROUPING VAR
MAX VARP
AVG
Returns the average of the values in a group. Syntax:
AVG ( [ ALL | DISTINCT ] expression ) All
Applies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that AVG be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
CHECKSUM_AGG
Returns the checksum of the values in a group. Syntax:
CHECKSUM_AGG ( [ ALL | DISTINCT ] expression ) All
Applies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that CHECKSUM_AGG be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
COUNT
Returns the number of items in a group. Syntax:
COUNT ( { [ [ ALL | DISTINCT ] expression ] | * } ) All
Applies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that COUNT be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
*Specifies that all rows should be counted to return the total number of rows in a table.
COUNT_BIG
Same as Count expect it returns bigint
GROUPING
Indicates whether a specified column expression in a GROUP BY list is aggregated or not.
Syntax:GROUPING ( <column_expression> )
column_expressionIs a column or an expression that contains a column in a GROUP BY clause.
MAX
Returns the maximum value in the expression. Syntax:
MAX ( [ ALL | DISTINCT ] expression ) All
Applies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that MAX be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
MIN
Returns the minimum value in the expression. Syntax:
MIN ( [ ALL | DISTINCT ] expression ) All
Applies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that MIN be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
SUM
Returns the sum of all the values. Syntax:
SUM ( [ ALL | DISTINCT ] expression ) All
Applies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that SUM be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
STDEV
Returns the statistical standard deviation of all values in the specified expression.
Syntax:STDEV ( [ ALL | DISTINCT ] expression )
AllApplies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that STDEV be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
STDEVP
Returns the statistical standard deviation for the population for all values in the specified expression.
Syntax:STDEVP ( [ ALL | DISTINCT ] expression )
AllApplies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that STDEVP be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
VAR
Returns the statistical variance of all values in the specified expression.
Syntax:VAR ( [ ALL | DISTINCT ] expression )
AllApplies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that VAR be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
VARP
Returns the statistical variance for the population for all values in the specified expression.
Syntax:VARP ( [ ALL | DISTINCT ] expression )
AllApplies the aggregate function to all values. ALL is the default.
DISTINCTSpecifies that VARP be performed only on each unique instance of a value, regardless of how many times the value occurs.
ExpressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
Resources
Aggregate Functions (books Online) http://bit.ly/dAaXRl
SQL Server 2008, Dev Edition http://bit.ly/L2hJQ
My TwitterSaidSalomon