K
K
Kolers2021-02-12 23:48:14
SQL
Kolers, 2021-02-12 23:48:14

How to take the next value after a certain one in a select?

How to take the next value from the select, but bind it to the current one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-02-13
@rozhnev

Use the LEAD function:

select 
  id,
  Month,
  LEAD(Month) OVER (ORDER BY Id) NextMonth
from Months;

MS SQL Fiddle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question