2

I have the database in MySQL like this

id employee_id  salary
1    1          10000
2    2          20000
3    3          10000
4    4          40000
5    5          30000

I want to select the maximum two salary by using LIMIT.So how to select that?

2 Answers 2

6

Just sort your results in descending order of salary and limit the resultset as desired:

SELECT * FROM mytable ORDER BY salary DESC LIMIT 2

See it on sqlfiddle.

Sign up to request clarification or add additional context in comments.

Comments

1
SELECT 
  employee_id,
  salary 
From
  employee 
order by salary desc 
limit 2 ;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.