SQL Database Concepts Question:

Explain what is ROW_NUMBER function?

Tweet Share WhatsApp

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 PDF Read All 113 Basic SQL Server Questions
Previous QuestionNext Question
Explain what is Public Role in SQL Server?Tell me about BuiltinAdministrator?