Eid | Ename | Age | City | Salary |
---|---|---|---|---|
E001 | ABC | 29 | Pune | 20000 |
E002 | PQR | 30 | Pune | 30000 |
E003 | LMN | 25 | Mumbai | 5000 |
E004 | XYZ | 24 | Mumbai | 4000 |
E005 | STU | 32 | Bangalore | 25000 |
Aggregate Functions | Description | Syntax | Example | Output |
---|---|---|---|---|
AVG | It returns the average of the data values. | SELECT AVG <column_name> FROM <table_name>; | SELECT AVG(Salary) FROM Employee; | AVG(Salary) 16800 |
MAX | It returns the maximum value for a column. | SELECT MAX <column_name> FROM <table_name>; | SELECT MAX(Salary) FROM Employee; | MAX(Salary) 30000 |
MIN | It returns the minimum value for a column. | SELECT MIN <column_name> FROM <table_name>; | SELECT MIN(Salary) FROM Employee; | MIN(Salary) 4000 |
SUM | It returns the sum (addition) of the data values. | SELECT SUM <column_name> FROM <table_name>; | SELECT SUM(Salary) FROM Employee WHERE City='Pune'; | SUM(Salary) 50000 |
COUNT() | It returns total number of values in a given column. | SELECT COUNT <column_name> FROM <table_name>; | SELECT COUNT(Empid) FROM Employee; | COUNT(Empid) 5 |
COUNT(*) | It returns the number of rows in a table. | SELECT COUNT(*) FROM <table_name>; | SELECT COUNT(*) FROM Employee; | COUNT(*) 5 |