Reputation: 850
Below query is not working in MySql.
SELECT * /*This is the outer query part */
FROM Employee Emp1
WHERE (N-1) = ( /* Subquery starts here */
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)
help me out.
Upvotes: 1
Views: 80
Reputation: 172458
Try this:
SET @n := 0;
SELECT * FROM
(SELECT salary, @n := @n + 1 AS t1 FROM Employee ORDER BY salary DESC)
AS t
WHERE t1 <= 5
Upvotes: 5