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 |
|
yeoryuel
Starting Member
9 Posts |
Posted - 2009-05-26 : 23:46:55
|
| Select deptno, max(sal) from emp group by deptno) is my successful subquery.but it throws error when i tried to give all the details of departmentwise maximum salary holders.Select * from emp where (deptno, sal) in (Select deptno, max(sal) from emp group by deptno).am a newbee. is my query illegible? ThanX.Success Code: "Impress Yourself" |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-26 : 23:55:18
|
You can't have the subquery returning 2 columns.use INNER JOINselect e.*from emp e inner join ( select deptno, max_sal = max(sal) from emp group by deptno ) m on e.dept_no = m.dept_no and e.sal = m.max_sal KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|