SQLite Forum

How to implement a table working like a ring buffer
Login
I had made a mistake in my description.

ID 	| GroupID 	| Ack
1	| 100		| 0
2	| 200		| 1
3	| 200		| 0
4	| 300		| 0
5	| 300		| 0
6	| 400		| 0
7	| 400		| 0

2.0) A row is not the "oldest row", if its Ack is 1.

2.1) A row is not the "oldest row", if the previous row of his goup (same GroupId) has Ack == 1 and this row is the last with Ack==0.

So: In the upper sample table the "oldest row" is ID = 4 and will be deleted if necessary (Because: ID=3 is part GroupId 200 and previous group member (ID=2) has Ack==1 AND ID=3 is the last of GroupId 200 with Ack==0. So ID=3 is not the "oldest row").

I attempt to solve this on the solution of Keith, without any success.