Answers

Question and Answer:

  Home  Basic SQL Server

⟩ Explain what is ROW_NUMBER function?

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.

 179 views

More Questions for you: