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),
	Aisle INT,
	Aisle_Side Varchar(1),
	Bay INT,
	X INT,
	Y INT
)

INSERT INTO @temp
values (5, 'L', 1, 5, 5), (5, 'R', 1, 10, 5), (5, 'R', 2, 10, 10), (5, 'L', 2, 5, 15), 
(5, 'L', 3, 5, 20), (5, 'R', 3, 10, 25), (5, 'L', 4, 5, 30), (5, 'R', 4, 10, 30)

Select *, 
DENSE_Rank() OVER (ORDER BY Y ASC) AS DenseRank,
(2 * (DENSE_Rank() OVER (ORDER BY Y ASC)) - 
  (
    CASE Aisle_Side WHEN 'L' THEN 1 ELSE 0 END
  )
) AS TranslatedBay
from @temp order by ID

Enter Parameters

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