June 18, 2009 at 6:13 am
Hi folks,
i have two tables Employee and salary. Employee having the columns empid, name and address and salary table having the columns empid and salary. i want optimize query to get the employee details who is having the max salary.
i can write query as
select * from employee where empid = (select empid from salary where salary = (select max(salary) from salary))
but is there any optimum query other than this?
thanks,
Ramu
June 18, 2009 at 6:17 am
SELECT TOP 1 Employee.*
FROM Employee inner join salary on employee.empid = salary.empid
Order by Salary DESC
Test it out and see if it's better or worse than the one that you have.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply