[Solved] How to determine next row value using select and case in SQL server?


You can combine CASE with LEAD(). Assuming you are ordering by stepthe query can look like:

select
  t.*,m
  case when lead(letter) over(order by step) = 'D' 
       then 1 else 0 end as is_next_row_letter_d
from t

solved How to determine next row value using select and case in SQL server?