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 |
|
keshavagrawal89
Starting Member
1 Post |
Posted - 2009-07-08 : 06:55:55
|
| i have a table named emp wid colmns : eid, ename, designation, salary. Now i want all the information abt the employee getting maximum salary in their respective designations...I used d followin querry : Select * from emp where salary in (select max(sal) from emp group by designation);But this doesnt work for similar values in salary column...can anyone plaese help me out of this.... |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-08 : 07:14:25
|
Can you give example data and wanted output please? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-07-08 : 09:32:57
|
| use ROW_NUMBER() |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 10:57:28
|
quote: Originally posted by keshavagrawal89 i have a table named emp wid colmns : eid, ename, designation, salary. Now i want all the information abt the employee getting maximum salary in their respective designations...I used d followin querry : Select * from emp where salary in (select max(sal) from emp group by designation);But this doesnt work for similar values in salary column...can anyone plaese help me out of this....
SELECT e1.*FROM emp e1JOIN (SELECT designation,MAX(sal) FROM greatest FROM emp GROUP BY designation) e2ON e2.designation=e1.designationAND e2.greatest=e1.sal |
 |
|
|
|
|
|