SQL COUNT (): This function returns the number of rows in the table that satisfies the condition specified in the WHERE condition. If the WHERE condition is not specified, then the query returns the total number of rows in the table.
For Example: If you want the number of emps in a particular department, the query would be:
SELECT COUNT (*) FROM emp
WHERE deptno = 10;
If you want the total number of emps in all the department, the query would take the form:
SELECT COUNT (*) FROM emp;
SQL DISTINCT(): This function is used to select the distinct rows.
For Example: If you want to select all distinct department names from emp table, the query would be:
SELECT DISTINCT deptno FROM emp;
To get the count of emps with unique name, the query would be:
SELECT COUNT (DISTINCT name) FROM emp;
SQL MAX(): This function is used to get the maximum value from a column.
To get the maximum salary drawn by an emp, the query would be:
SELECT MAX (salary) FROM emp;
SQL MIN(): This function is used to get the minimum value from a column.
To get the minimum salary drawn by an emp, he query would be:
SELECT MIN (salary) FROM emp;
SQL AVG(): This function is used to get the average value of a numeric column.
To get the average salary, the query would be
SELECT AVG (salary) FROM emp;
SQL SUM(): This function is used to get the sum of a numeric column
To get the total salary given out to the emps,
SELECT SUM (salary) FROM emp;