Hello everyone, I have this query that reports data on a specific donor (I work at a school) . It includes their largest donation, last donation, first donation, and sums of donations. I need to do two things: I need to change it to report this information for all donors in the table not just the ID I have specified and I need to add a collumn to compute the sum of all gifts of type 'NP'. The problem is that for all other computed collumns I only needed information on gifts of type 'PP' or 'GF' so I dont know how to add this one collumn. Any help is greatly appreciated. Thank you. And thanks to those who have already helped me come up with parts of this query.
where pv.ID = '0000959';
Since you need a report for all users instead of the specified one, just remove the where pv.ID = '0000959' part. Adding a sum of all donations of type NP will require a small change in the code. Because you need to consider this type as well, it needs toi be added to the list of contrib_type values, currently listing only GF and PP. On the other hand, because other calculations should include only those types, you need to explicitly filter the other type in your case statements. For example, I remember that to calculate the largest amount you originally wanted to only consider GF types. If this is the case then you need to adjust the case statement accordingly. Currently, this line reads:
If you need to consider only the amounts for contrib_type = 'GF' then this line should instead read this:
etc. This adjustment aside, here is the query which reports for all users and includes the additionaly column you need: