Considering a table with:
common_id id result
10 1 8
10 2 10
10 3 4
10 1 7
10 2 5
10 3 2
I want just the last "batch" -- in this case, the last 3 results - but the number of ids in the batch can be different each time (*per a certain common_id
). You can assume that each "batch" has the same ids, their order might be different though. So a "batch" is a series of ids that ends with a row having an id that already appeared (again, a batch is per a common_id
).
What query can achieve this?