Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL query question

Author  Topic 

Dufresne
Starting Member

5 Posts

Posted - 2009-06-30 : 04:12:28
Hi! I'm new at SQL.
I'm using Oracle Sql Developer.

Question is :
Find the department_id which has maximum number of employee.

I can group departments and display total number of employees that each department has , but when i use max() function
I get error
"Group function is too deeply."

How can i solve this problem?

My SQL code is :

-- this code display deparments and total employees
select department_id , count( department_id ) TOTAL
from employees
group by department_id ;

-- this code gives error
select department_id , count( department_id ) TOTAL
from employees
group by department_id
having count( department_id) = max( count( department_id));

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-30 : 04:13:42
this is a MS SQL Server forum. For Oracle question, try posting at dbforums.com


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Dufresne
Starting Member

5 Posts

Posted - 2009-06-30 : 04:20:32
Ok
Go to Top of Page
   

- Advertisement -