Rank(),Dense_Rank(),Row_Number() Syntax

The following post is about Rank(),Dense_Rank() and Row_Number() T-SQL Commands.

declare @t table(FranchiseName varchar(200),AssociatedCity varchar(20),Sport varchar(200))
Insert into @t values
('Mavericks','Dallas','NBA'),
('Knicks','New York','NBA'),
('CowBoys','Dallas','NFL'),
('Gaints','New York','NFL'),
('49ers','San Francisco','NFL')

;with CTE AS
(select *,Row_number() Over(Order by AssociatedCity) as [RowNumber] from @t T)
select * from CTE

RowNumber

;with CTE2 AS
(select *,RANK() Over(Order by AssociatedCity) as [Rank] from @t T)
select * from CTE2

Rank

;with CTE3 AS
(select *,DENSE_RANK() Over(Order by AssociatedCity) as [DenseRank] from @t T)
select * from CTE3

DenseRank