Mohsin Arif

Mohsin Arif

  • 311
  • 6k
  • 137.7k

Get difference of salary row by row ?

Apr 10 2020 7:48 AM
hellow guys  i have some data in tables like this 
 
Data in our table:
              EmpName   Salary 
Row 1. EmpName1, 10000
Row 2. EmpName2, 20000
Row 3. EmpName3, 12000
 
i want to get highest salary and minus 2nd highest and show diifrence like this 
 
               Empname    Salary Diifrence
Row 1. EmpName2, 20000, 8000
Row 2. EmpName3, 12000, 2000
Row 3. EmpName1, 10000, NULL
 
 
how can i get this in sql server please some one to help me 
 
 
 

Answers (1)