Using Group Functions - Avg, Sum, Min, Max and Count
Using the AVG and SUM Functions :- You can use AVG and SUM for numeric data
- SELECT AVG(sal), MAX(sal), MIN(sal), SUM(sal) FROM emp WHERE job LIKE '%MAN%';
Using the MIN and MAX Functions :- You can use MIN and MAX for numeric, character, and date data types
- SELECT MIN(hiredate), MAX(hiredate) FROM emp;
Using the COUNT Function :- COUNT(*) returns the number of rows in a table
- SELECT COUNT(*) FROM emp WHERE deptno = 10;
- COUNT(expr) returns the number of rows with non-null values for the expr
- SELECT COUNT(comm) FROM emp WHERE deptno = 30;
Using the DISTINCT Keyword :- COUNT(DISTINCT expr) returns the number of distinct non-null values of the expr
- To display the number of distinct department values in the EMP table
- SELECT COUNT(DISTINCT deptno) FROM emp;
No comments:
Post a Comment