2017-03-28

找出由大到小第N個項目

找出由大到小第N個項目,蠻有創意的SQL寫法

SELECT * FROM Employee Emp1 
WHERE (N-1) = 
(
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary
)

沒有留言:

張貼留言