Can Multiple Columns Be Used in GROUP BY in Oracle?
Submitted by: AdministratorYou can use multiple columns in the GROUP BY clause as shown in the following example. It returns how many employees are having the same salary in each department:
SQL> SELECT department_id, salary, count(*)
2 FROM employees GROUP BY department_id,
3 salary HAVING count(*) > 1;
<pre>DEPARTMENT_ID SALARY COUNT(*)
------------- ---------- ----------
90 17000 2
50 3200 4
50 2200 2
50 3600 2
80 10500 2
80 9000 2
50 2700 2
......</pre>
Submitted by: Administrator
SQL> SELECT department_id, salary, count(*)
2 FROM employees GROUP BY department_id,
3 salary HAVING count(*) > 1;
<pre>DEPARTMENT_ID SALARY COUNT(*)
------------- ---------- ----------
90 17000 2
50 3200 4
50 2200 2
50 3600 2
80 10500 2
80 9000 2
50 2700 2
......</pre>
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | What Happens If Recursive Calls Get Out of Control? |
☺ | What Happens to Indexes If You Drop a Table? |
☺ | What Are the Logical Operations? |
☺ | What Is a Table Index in Oracle? |
☺ | How To Write a Query with a Right Outer Join in Oracle? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |