Saturday, 5 May 2012

Sql Server material 14


Set Operators:

COUNT(expression): Returns the number of items in a group.
            SELECT COUNT(*) FROM EMP
            SELECT COUNT(*) FROM EMP WHERE DEPTNO=20
            SELECT COUNT(COMM) FROM EMP

COUNT_BIG(expression): COUNT_BIG works like the COUNT function. The only difference between the two functions is their return values. COUNT_BIG always returns a bigint data type value. COUNT always returns an int data type value.
            SELECT COUNT_BIG(*) FROM EMP

SUM(expression): Returns the sum of all the values. SUM can be used with numeric columns only. Null values are ignored
            SELECT SUM(SAL) FROM EMP

AVG(expression): Returns the average of the values in a group. Null values are ignored.
            SELECT AVG(SAL) FROM EMP

MAX(expression): Returns the maximum value in the expression.
            SELECT MAX(SAL) FROM EMP

MIN(expression): Returns the minimum value in the expression.
            SELECT MIN(SAL) FROM EMP

STDEV(expression): Returns the statistical standard deviation of all values in the specified expression.
            SELECT STDEV(SAL) FROM EMP

VAR(expression): Returns the statistical variance of all values in the specified expression.
            SELECT VAR(SAL) FROM EMP

<<< Previous                                                                                                                             Next >>>

No comments:

Post a Comment