As far as I understand, your requirement is something like this -
A person is eligible for something, say some offer, only if that person has any of the visits within 30 day gap of another date. Is that correct? If I have understood the requirement correctly, then I would like to share the logic with which you can go ahead. At this point, I will not go into the programming but only the logic of it.
1) Find out eligible records. I guess a person has multiple records and only few records will be eligible. So first find out all the eligible records.
2) Once that is done, now we have to find out eligible persons and not records. If any of the record is eligible for a person, then the person becomes eligible. The person is not eligible only if any of the record of that person is not eligible. Hence find out eligible persons now.
3) Once you have eligible persons, keep only those (eligible) persons in the dataset and remove non eligible persons from the dataset.
Once you agree with the logic of the problem solving, please try to write programme for the same. If you do not agree with my articulation of the problem or if you think that I have not understood it correctly, please let me know it. Once you will start writing the programme with these 3 steps, feel free to let me know if you get stuck up somewhere.
Happy programming!
Thank you.
- Dr. Abhijeet Safai
... View more