16
Said Salomon Unitrin Direct Insurance timelord@timelordshangout. com T-SQL Aggregate Functions Said Salomon

Said Salomon Unitrin Direct Insurance [email protected] T-SQL Aggregate Functions Said Salomon

Embed Size (px)

Citation preview

Page 1: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

Said SalomonUnitrin Direct Insurance

[email protected]

T-SQL Aggregate FunctionsSaid Salomon

Page 2: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 4: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 5: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 6: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 7: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

COUNT_BIG

Same as Count expect it returns bigint

Page 8: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 9: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 10: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 11: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 12: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 13: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 14: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 15: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

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.

Page 16: Said Salomon Unitrin Direct Insurance timelord@timelordshangout.com T-SQL Aggregate Functions Said Salomon

Resources

Aggregate Functions (books Online) http://bit.ly/dAaXRl

SQL Server 2008, Dev Edition http://bit.ly/L2hJQ

My TwitterSaidSalomon