some guys confused how to write a query for getting output in sql server. there are so many way to get Nth salary .......... i am explaining two ways below find : select * from (select Dense_Rank() over (order by salary desc) as denserank,salary from SalaryMaster) as r where denserank= Value Value=on which position rank you want i.e. 2 or 5th this is a Dense_Rank() function which gives you a sequence without skipping a number order. this is the best way to get Nth salary in a query. -------------------------------------------------------------------- 2nd way. with CTE with CTESalary AS ( Dense_Rank() over (order by salary desc)as denserank, ,salary from SalaryMaster ) select * from CTESalary where denserank=2
SELECT [name] ,create_date ,modify_date FROM sys.tables where create_date >='03/01/2015' SELECT * FROM sys.procedures WHERE create_date >='03/01/2015' SELECT * FROM sys.objects WHERE type IN ('FN', 'IF', 'TF') -- scalar, inline table-valued, table-valued
Comments
Post a Comment