I have a table of data which contains attributes like body, offer_id and created_at. When in chronological order I need to find the count of rows until 'body' satisfies my 'where' clause for a particular offer_id, i.e.
created at | offer id | body
---------------------------------------------
Jan | 12 | does not satisfy
Feb | 12 | does not satisfy
Mar | 12 | satisfies
Jan | 13 | does not satisfy
Feb | 13 | satisfies
Jan | 14 | does not satisfy
Feb | 14 | satisfies
Mar | 14 | does not satisfy
Apr | 14 | does not satisfy
Expected output:
offer_id | count
---------|------
12 | 3
13 | 2
14 | 2