Syntax: Select (Columns List) From Tablename Group by Column Name
Syntax: Select (Columns List) From Tablename Group by Column Name
Syntax: SELECT {COLUMNS LIST} FROM TABLENAME GROUP BY COLUMN NAME E.g.: SELECT DEPTNO !"# $S"L% "S &'S"L !'N $S"L% "S LOS"L S(! $S"L% "S TOTS"L ")* $S"L% "S ")*S"L +,O! E!P *,O(P -. DEPTNO DEPTNO /0 30 HISAL /1000 30000 LOSAL 1000 1000 TOTSAL 20000 31000 AVGSAL /0000 /3100
HAVING CLAUSE: This clause is used to evaluate a condition 4ith group b5 clause. *enerall5 for evaluating conditions 4e 4ill use 6&E,E clause but 4here clause does not support b5 group b5 clause. Syntax: SELECT STATEMENT GROUP BY COLUMN NAME [HAVING CONDITION] E.g.: SELECT DEPTNO !"# $S"L% "S &'S"L !'N $S"L% "S LOS"L S(! $S"L% "S TOTS"L ")* $S"L% "S ")*S"L +,O! E!P *,O(P -. DEPTNO &")'N* ")* $S"L%7/0000 DEPTNO 30 HISAL 30000 LOSAL 1000 TOTSAL 31000 AVGSAL /3100
SPECIAL FUNCTIONS COUNT( ): Count function counts the number of ro4s available for a specific column. 't counts onl5 values e8cept N(LL values. 't is associated 4ith three parameters. CO(NT $9% CO(NT $Column Name% E.g.: SELECT CO(NT $9% "S NO:O+:,O6S +,O! E!P NO:O+:,O6S 1
E.g.: SELECT CO(NT $DEPTNO% "S NO:O+:,O6S +,O! E!P NO:O+:,O6S 1 DISTINCT ( ): This function displa5s the different values available for a specific column. 't considers one N(LL value. E.g.: SELECT D'ST'NCT $DEPTNO% "S D'++:)"L(ES +,O! E!P D'++:)"L(ES /0 30 E.g.: SELECT CO(NT $D'ST'NCT$ DEPTNO%% "S NO:O+:,O6S +,O! E!P NO:O+:,O6S 3 Note: CO(NT function does not count the ro4s of the column 4hose data t5pe is -'*'NT 'n such situations 4e have to use COUNT_BIG function