select max(emp_salary),emp_name from emp_table
what is the error in this command?....can,t we use any other statement while using max or min functions?..........emp_salary...is employee salary.....emp_name is employee name.....emp_table is employee table
Answer by RickD ·
Or, you can do
select max(emp_salary),emp_name from emp_table group by emp_name
If you want to find the higest salary for each employee (this would assume that you have historical data).
I am guessing TG's answer is really the one you want though..
Answer by TG ·
If you just one the single highest salaried employee you can do this:
select top 1 emp_name, emp_salary from emp_table order by emp_salary desc
Aggregate functions need to either not be combined with non-aggregate expressions (like columns) or you need to GROUP BY whatever columns you don't want to aggregate.