On Aug 30, 2011, at 3:55 PM, Simon Spero wrote: > On Tue, Aug 30, 2011 at 12:56 PM, Ken Irwin <[log in to unmask]> wrote: > >> I have a feeling it may be time for me to learn some grown-up programming >> skills, and I hope someone here might be able to help. [trimmed] > Sometimes it can make sense to use the database to do the aggregation; e.g. > > CREATE TABLE Summary AS > SELECT inst,patron_type,item_barcode,min(date) "first", > min(call_no),min(renewals) "min_renewals", max(renewals) "max_renewals" > FROM Renewals > GROUP BY inst,patron_type,item_barcode; Wow ... I didn't realize I was that asleep. No wonder I had such an unproductive day. I'll second Simon's recommendation. There's no reason to pull this into PHP if you can do it all in the database, which is quite likely based on what was described. -Joe