LeetCode Medium 177 "Nth Highest Salary" Amazon Bloomberg Interview SQL Question With Explanation

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 6

  • @jeroldmorphy3764
    @jeroldmorphy3764 Год назад +3

    man you are wonderful. You are the only I guy I have seen that writes FROM before SELECT, which is how it should be

  • @devsagar5812
    @devsagar5812 5 месяцев назад +2

    Alternative if interviewer ask to not to use windows functions:
    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    SET N = N-1;
    RETURN (
    # Write your MySQL query statement below.
    select
    distinct salary
    from Employee
    order by salary desc
    limit 1 offset N
    );
    END

    • @tejaswaniguttula5961
      @tejaswaniguttula5961 4 месяца назад

      @devsagar
      can you tell how it works fine with this test case??
      | id | salary |
      | -- | ------ |
      | 1 | 100 |
      | 2 | 100 |

  • @needoa487
    @needoa487 2 года назад

    can you explain why u write in code where rnk = n

    • @minakshi_119
      @minakshi_119 Год назад +1

      n could be anything 1,2,3, and rnk is the name given to over(order by sal desc)