SQL Database Concepts Question:

Download Job Interview Questions and Answers PDF

Explain what is ROW_NUMBER function?

Basic SQL Server Interview Question
Basic SQL Server Interview Question

Answer:

RANK is one of the Ranking functions which are used to give rank to each row in the result set of a SELECT statement.
For using this function first specify the function name, followed by the empty parentheses.
Then specify the OVER function. For this function, you have to pass an ORDER BY clause as an argument. The clause specifies the column(s) that you are going to rank.
For Example
SELECT ROW_NUMBER() OVER(ORDER BY Salary DESC) AS [RowNumber], EmpName, Salary, [Month], [Year] FROM EmpSalary
In the result you will see that the highest salary got the first rand and the lowest salary got the last rank. Here the rows with equal salaries will not get same ranks.

Download Basic SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
Explain what is Public Role in SQL Server?Tell me about BuiltinAdministrator?