Step1 : ROW_NUMBER()

rowno1

 

SELECT FirstName,
ROW_NUMBER() OVER (ORDER BY FirstName) AS ‘Row_no’
FROM tblEmployee
where FirstName =‘Nagendra’

1

Step 2 : RANK()

rank1

SELECT FirstName,
Rank() OVER (ORDER BY FirstName) AS ‘Row_ID’
FROM tblEmployee
where FirstName =‘Nagendra’ or FirstName =‘Ashok
order by FirstName

rank2

Step 3 : DENSE_RANK()

SELECT FirstName,
DENSE_RANK() OVER (ORDER BY FirstName) AS ‘Row_ID’
FROM tblEmployee
where FirstName =‘Nagendra’ or FirstName =‘Ashok’
order by FirstName

denserank1

Step 4 : DENSE_RANK() with DISTINCT

denserank2

happ