Lets say we got a support-software where customer can simply stand in queue when it's full. The queue-index will increase with ++n for each customer in queue. Index 0 means you're no longer in queue.
However, in a scenario where a customer choose to leave the queue, the other customer after him wont have their queue-index decreased. Lets say his index was 3, and there was total 5 customer in line.
Means: 1,2,3,4,5
led to -> 1,2,4,5
and that's really terrible. Instead, I want it to correct the rest of the queue properly and decrease everyone above the hatch til there's no more hatch.
How do I correct the queue order with a SQL syntax, where it check if there's any hatch, if so, correct it?