«

»

Oct 25

how to get second highest salary in sql

Hi,

In this article I will explain you a common interview question

Question : How you will get second highest salary from  Employee table

Ans:  Just simply Explain this below query and Scenario

Below Image shows you Employee table data

s1

Execute below query:

[code language=”sql”]

SELECT MAX(EmployeeSalary) AS SecondHighestSalary FROM Tbl_Mst_Employee

WHERE  EmployeeSalary < (SELECT MAX(EmployeeSalary) FROM Tbl_Mst_Employee)

[/code]

o/p:

s2

 

Happy Coding!!!!

Admin.

 

1 comment

  1. Leatrice

    So much info in so few words. Toltsoy could learn a lot.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>