You're on the right track. You filter aggregate functions like MAX() and SUM() using having . In a query like this, you should probably add a group otherwise you'll end up with a lot of duplicated data in your result when a Distributor has multiple notes on the same day (assuming t.id is a primary key).
Second, you should use named params instead of putting variables directly into SQL. So, instead of compare('last_note'... you'd end up with something like this.
In order for filtering to work, you should have a class attribute to store the data.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.