function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chance @ GranthamChance @ Grantham 

Reporting and single attribution on child objects

I have a best practices question for you.
We have created a child object to lead/contact called Inquiries. The inquiry is a single submission of a form or an expression of interest. This is primarily used for marketing information. Marketing has an additional request: which inquiry has the primary attribution when particular milestones are met (registration, application, etc). Their idea is that if an inquiry comes in within 30 days of another, that the second one was "influenced" by the first, and should not get attribution. 
An example: inquiries come in 90 days ago, 15 days ago, and then again yesterday. If they apply (reach a milestone) today, then the second inquiry should be the one with attribution.
What is the best way to get a lead and then get the inquiry that has primary attribution? How are others solving this question?
My understanding is that native SF reporting would not be able to handle this in report builder. Simply because we cannot iterate over the inquiries, nor can we do comparative filters (most recent inquiry, inquiries less than 30 days than that inquiry). 
So I believe that we will need to do some data manipulation on either the lead or inquiry object. I have experience with apex and am comfortable building it out. As I understand, as well, I cannot create a lookup on the lead to the inquiry, as that would create a circular reference when the inquiry is both the child and the parent of the lead.
How would you build this in your org? Would you simply perform this reporting in SQL? Would you create fields on the lead that house information from the "winning" Inquiry?