If I have a row id and I want the 5th row back from that row how would I do this?
Normally I could just go
rowId - 5
and that would be the id of the 5th row back...
However, I need to account for if a row has been deleted, this would mean that, for example
39, 40, 41, 42, 43, 44, 45
if rowId was 45, then I would get rowId of 40 for my 5th row back, but if row 42 was deleted, then we would have...
39, 40, 41, 43, 44, 45
and the rowId of 45 would give me a rowId of 40 again, when it should be giving me 39 (because it is the 5th row back).
I can't think of any way to get around this, I can't renumber the id's after a deletion because the table may grow to be a million rows long. Anyone have any ideas?
Thanks, Matt