You could sort then group, pushing values from col + i to fields and then reduce those to pick the first or last populated values in the aray.
Do you have the query you have so far along with sample data and expected outcome?
What does the data look like in terms of volume and population?