Skip to content
Advertisement

How to get next step

I have the table request_step with dummy info like bellow

I want to take the next steps(pending state) per request_id and the previous steps must not have any rejected state. I mark an asterisk before line to show which one I want to query

I already have a sql script to return me all the next steps but I can not find a solution to check if the previous steps have rejected

Advertisement

Answer

I think you want to look at lag():

EDIT:

If you want to check all previous steps, then you can do something similar with a cumulative sum:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement