Declare @POG 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)

Audio-Video Production Meta

Q&A about the site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation

Declare @POG as Table
(
	ID INT PRIMARY KEY IDENTITY(1, 1),
	Aisle INT,
	Aisle_Side Varchar(1),
	Bay INT,
	X INT,
	Y INT
)

INSERT INTO @POG
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 DESC) AS DenseRank,
(2 * (DENSE_Rank() OVER (ORDER BY Y DESC)) - 
  (
    CASE Aisle_Side WHEN 'L' THEN 1 ELSE 0 END
  )
) AS TranslatedBay
from @POG order by ID

Enter Parameters

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