I have this Table with one row Transaction Date
the first row is the checkIn
and the second one is the Checkout
if we organized the result by date asc.
I need to pass the second row value to another column named Checkout
. This table has at least 1000 records
Advertisement
Answer
Try using the query below
With CteCheckOut as( Select ROW_NUMBER() over (Partition by studentID Order by studentID,transactionDate) as Rownumber, * From student ) Select studentID, transactionDate as CheckOutDate From CteCheckOut Where Rownumber%2 = 0