Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  View Answers    Answer this question    Ask a question  
 

Kalpana_pipl
Aug 14, 2008, 01:16 AM
Hi all,

How to select a field that is not a part of the Group By clause?

Suppose a table contains Emp_No, Emp_Name,Dept_No,Salary...
I have to select the emp_no or emp_name who are get the maximum salary in Dept_No wise..
How do I achieve this through a single SQL ?
guide me

Thanks is advance...

ordba
Dec 8, 2008, 04:16 PM
Try and use subselect...

Select emp_name from
(select emp_name,dept_no,max(salary) from emp group by emp_name,dept_no);