Originally Posted by IslandRed
That kind of depends on what you mean by "immediately following." SQL queries are set-based and it doesn't have a concept of sequential records except where you might have set up a unique key field to hold the incrementing values.
If you can go into more detail on what you're trying to do, I'll help if I can.
I am trying to extract information from PBP records from the Retrosheet baseball database, in this case.
In their records, it shows a playerID for each base occupied when the player is at-bat as well as the number of outs. What I want to do is find the total bases advanced by all baserunners from a plate appearance, which can only be done based on the circumstances of the plate appearance below it (as it's in sequential order).
So if a batter is up with one out and showing a runner occupying first, I would need to know the bases being occupied beginning the next plate appearance as well as the number of outs and updated score on the next line to know how many bases were gained.
I will send a more detailed example to you if this is still confusing. I might not be explaining it very well.