Find max and second max salary for a employee table MySQL

前端 未结 30 1915
忘掉有多难
忘掉有多难 2020-12-12 21:19

Suppose that you are given the following simple database table called Employee that has 2 columns named Employee ID and Salary:

  Employee
  Employee ID    S         


        
30条回答
  •  眼角桃花
    2020-12-12 21:40

    This will work To find the nth maximum number

    SELECT 
        TOP 1 * from (SELECT TOP  nth_largest_no * FROM Products Order by price desc) ORDER BY price asc;
    

    For Fifth Largest number

    SELECT 
      TOP 1 *  from (SELECT TOP  5 * FROM Products Order by price desc) ORDER BY price asc;
    

提交回复
热议问题