Declare @temp as Table ( ID INT PRIMARY KEY IDENTITY(1, 1),

0

Please login or register to vote for this query.

(click on this box to dismiss)

Android Enthusiasts

Q&A for enthusiasts and power users of the Android operating system

Declare @temp as Table
(
	ID INT PRIMARY KEY IDENTITY(1, 1),
	Direction Varchar(1),
	Bay INT
)

INSERT INTO @temp
values ('L', 1), ('R', 1), ('R', 2), ('L', 2), ('L', 3), ('R', 3), ('L', 4), ('R', 4)

Select *, 
Row_Number() OVER (PARTITION BY Direction ORDER BY ID ASC) AS RowNumber,
Rank() OVER (PARTITION BY Direction ORDER BY Bay ASC) AS Rank
from @temp order by ID

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results