one single programmer

I've started doing some independent work on the side. This has opened my eyes to somethings and I plan to write about it as time permits.

Sunday, January 07, 2007

Crystal Report - eliminate duplicates

I recently had a problem where I had to report the most recent changes to benefits on a report for a specific employee.  The table was a change management table and listed the history of changes.  It took quite a few tables to achieve all the data and I didn’t have the services of ms sql so ended up using crystal reports exclusively.  What I learned was really cool.  I did the resulting query as though I didn’t care about duplicates and then grouped them by the benefit id.  Then in select formulas for groups I used the maximum function like this

 

Benefit.submitdate = maximum (benefit.submitdate, benefit.id)

 

This returns only the benefit with the maximum submit date and solved all my problems.