I needed to select a few fields from a couple of databases in a data warehouse. The record selection was very easy

{Field} ="Criteria" and
({Field} like "*Criteria* Wildcard*")

I also added a group selection to get the latest data

{Field1}=maximum({Field1},{Field2 Used to Group Data}).

The problem started when I added a third database. I checked the joins and they are all on one or two primary keys. I checked the duplicate data and they are exactly the same down to the timestamp. How do I remove the duplicates? I tried to use distinct but it did not work and I had to remove it from the record selector. Can someone help me?