How to find Nth highest salary in sql server

Query to get nth Highest Salary

Select TOP 1 Salary as ‘N Highest Salary’ from
(
SELECT DISTINCT TOP Salary from Employee ORDER BY Salary DESC
) a
ORDER BY Salary ASC

Replace N with the number. Continue reading

Advertisements

Some SQL questions

Differences between a Stored Procedure and a Trigger

A stored procedure is a group of SQL statements that is compiled one time, and then can be executed many times. A trigger is a special kind of stored procedure. It is attached to a table and only triggers when an insert, update or delete occurs. Continue reading

By Sriramjithendra Posted in SQL Q&A

COALESCE vs. ISNULL SQL SERVER

The COALESCE and ISNULL T-SQL functions are used to return the first nonnull expression among the input arguments. SQL Server practitioners often wonder what the difference is between the two functions. Several differences exist; some are straightforward and are common knowledge, whereas others are less straightforward and are less well-known. Continue reading