SQL tutorial | Interview questions | Oracle
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Can Multiple Columns Be Used in GROUP BY?

Go down

Can Multiple Columns Be Used in GROUP BY? Empty Can Multiple Columns Be Used in GROUP BY?

Post by Micheal Sun Jan 17, 2010 3:08 am

You 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(*)
FROM employees GROUP BY department_id, salary HAVING count(*) > 1;
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

Micheal
Admin

Posts : 243
Join date : 2010-01-10

http://sql-tutorial.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum