Aggregate Functions:
Oracle has many built-in functions which are used to process numbers or strings. They are very useful as we can directly use them , we just have to write the aggregate function name and in braces the column name on which we have to perform any calculations.
1. COUNT() function:
COUNT function is applied to those situation when we have to count the number of tuples(rows) in a table.
Example of COUNT function:
SELECT COUNT(Name) FROM Employee WHERE City = 'Dehradun';
The above query will count the number of names who belongs to city Dehradun.
2. MAX() Function:
It selects the maximum value from a column like if we need to find highest salary we can use MAX() function.
Example of MAX function:
SELECT MAX(AGE) FROM Employee;
The above query will fetch highest age from employee table.
3. MIN() Function:
It selects the minimum value from a column like if we need to find lowest salary we can use MIN() function.
Example of MIN function:
SELECT MIN(AGE) FROM Employee;
The above query will fetch smallest age from employee table.
4. AVG() Function:
It calculates the average value for a column on which it is applied.
SELECT AVG(Salary) FROM Employee;
The above query will fetch the average of Salary column.
5. SUM() Function:
It calculates the sum of all values for a column on which it is applied.
SELECT SUM(Salary) FROM Employee;
The above query will fetch the total sum of Salary column.
0 Comment(s)