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

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -