sql server - SQL Statement to find next move -


i have situation have find next value after current move.

currently have below:

 select convert(char(17), plannedstartdateutc,13)     visitmovement vm    vm.visitmovement_guid = (select vm2.visitmovement_guid                                   visitmovement vm2                                   vm2.orderindex = (visitmovement.orderindex +10)                                     , vm2.visit_guid = visitmovement.visit_guid )) [estimated move], 

which works using visitmovement.orderindex find next move. however, in situations orderindex might not +10 +20.

i can't understand how logically write find next move.

any more information please in touch.

you can use top 1 , order orderindex find next:

 select convert(char(17), plannedstartdateutc,13)     visitmovement vm    vm.visitmovement_guid =          (                 select top 1 vm2.visitmovement_guid                   visitmovement vm2                  vm2.visit_guid = visitmovement.visit_guid                 order vm2.orderindex) [estimated move], 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -