vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Tuesday, May 17, 2011

Aggregate Functions in SQL SERVER 2008


Aggregate functions are applied to a group of data values from a column. Aggregate functions always return a single value.


AVG: Calculates the arithmetic mean (average) of the data values contained within a column. The column must contain numeric values.

MAX and MIN: Calculate the maximum and minimum data value of the column, respectively. The column can contain numeric, string, and date/time values.

SUM: Calculates the total of all data values in a column. The column must contain numeric values.

COUNT: Calculates the number of (non-null) data values in a column. The only aggregate function not being applied to columns is COUNT(*). This function

returns the number of rows (whether or not particular columns have NULL values).

COUNT_BIG: New and Analogous to COUNT, the only difference being that COUNT_BIG returns a value of the BIGINT data type.

when using aggregate function 'where' keyword could not be used,Instead of  'where' Keyword 'Having' keyword is used in sql...

Examble for using aggregate function with Having Keyword..

SELECT stdname,SUM(total) FROM stdtable
WHERE stdname='raju' OR stdname='vikas'
GROUP BY stdname
HAVING SUM(total)>500

0 comments:

Post a Comment