I'm using an Oracle DB table to store orders that can have multiple events, and each of them has to be processed sequentially based on a version field.
The basic structure of this table contains 3 columns: Order ID; the aforementioned Version; and Processed, a simple 1/0 boolean flag to know if an order version was processed or not.
The processing of said orders is performed on batch, so what I'm struggling with it's writing a SELECT statement that gets, for each Order ID, the next unprocessed version on a single result set.
Does anybody have any idea how this could be achieved?