Generally you could use window functions to access previous or next rows in an ordered set.
Look for LEAD()/LAG() in the SQL language reference and you'll find examples for that.
For your example however, I don't see any inner logic to the order of your records.
So, why would the record DEF come after the second ABC and not after the third?