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.
| Author |
Topic |
|
chinlax
Starting Member
30 Posts |
Posted - 2011-10-12 : 22:29:16
|
| Hi All, I have an employ table which has following columnsempno, ename, job, sal, deptno, joiningdate i want to write a query to Display all the employees who are earning more than all the managers.I wrote the query like this:select sal from employ where sal >(select sal from employ where job='manager');but it will give error saying , it returns more than one value........can any one help me out in solving this problem.......Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-10-12 : 22:36:47
|
[code]select sal from employ where sal > (select max(sal) from employ where job='manager');[/code]quote: Display all the employees who are earning more than all the managers.
The sub query in blue will give you the highest salary of manager. Comparing against that will give you the result that you want KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
chinlax
Starting Member
30 Posts |
Posted - 2011-10-12 : 23:03:31
|
| Hi,select sal from employ where sal > (select max(sal) from employ where job='manager');This query takes only the max sal of all manager , in my table there are so many departments and in all department mangers are there.so i want the query to return the salary who are getting more than all managers ....i mean if say i have 3 managers,,,,,manager1=1000, manager2=4000, manager=1500......i want to write the query to select salary of all other employees, who are all getting more than all the managers.Thanks in advance |
 |
|
|
chinlax
Starting Member
30 Posts |
Posted - 2011-10-12 : 23:08:44
|
| Sorry your answer is correct..........i got confused.......it is working fineThanks |
 |
|
|
|
|
|
|
|