Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Fetching Second Highest Salary

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 657
    Comment on it

    If we want to find highest salary we can use max() function simply.

    Example:

    SELECT max(salary) FROM Employee;
    

    It will return the highest salary from Employee table.


    But if we need to find the second highest salary then we have to use sub query.

    Example:

    SELECT max(salary) FROM Employee
    where salary NOT IN (SELECT
    max(salary) FROM Employee);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: