This article is for knowing how some of the keywords in Oracle work:
1. GROUP BY - Group by clause allows us to group the data based on a column or a combination of columns. The main benefit of using this keyword is when we have to get the aggregated data.
Ex - We have to find the total number of employees working in different departments. The following query can be used for this.
1. GROUP BY - Group by clause allows us to group the data based on a column or a combination of columns. The main benefit of using this keyword is when we have to get the aggregated data.
Ex - We have to find the total number of employees working in different departments. The following query can be used for this.
SELECT dept_id, COUNT(emp_id)
FROM department d, employee e
WHERE e.dept_id = d.dept_id
GROUP BY dept_idThe same way we can use group by to get the sum or average of the salaries of different departments.