Explore BrainMass
Share

Explore BrainMass

    SQL query to find the second highest income/salary

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Write a query to find the second highest income/salary.

    Table: Income
    Emp_id Emp_name Dept Salary
    1 Anthony Gonzales Finance 100,000
    2 Timothy Dalton IT 94,000
    3 Maria D'souza Msci 79,000
    4 Monica Lee Clent Services 150,000
    5 Umesh Shah Engg 125,000
    6 John Reginald AppDev 73,000

    © BrainMass Inc. brainmass.com October 10, 2019, 3:13 am ad1c9bdddf
    https://brainmass.com/computer-science/sql/writing-query-find-second-highest-income-example-411565

    Solution Preview

    The query to find the second highest income/salary can be written as below:

    Select * from Income a
    where 2=(select count(*) from ...

    Solution Summary

    The solution contains an SQL query (tested in Microsoft SQL Server) to find the second highest salary value. It could be used to find in general any second largest column value in a table.

    $2.19