CREATE TABLE #EMP(Emp_Id INT, Name VARCHAR(20),Salary MONEY)
INSERT INTO #EMP(Emp_Id,Name,Salary)
VALUES
(1215 ,'Harish',20000),
(1234,'sai',30000 ),
(1245 ,'Satish',15000),
(1246 ,'santosh',20000);
;WITH CTE AS(
SELECT * ,DENSE_RANK()OVER(ORDER BY Salary) AS DN FROM #EMP
)
SELECT
Emp_Id
,Name
,Salary
FROM CTE WHERE DN in(1,2)
OUTPUT:-
Emp_Id| Name | Salary
1245 Satish 15000.00
1246 santosh 20000.00
1215 Harish 20000.00