Link to home
Start Free TrialLog in
Avatar of Auerelio Vasquez
Auerelio VasquezFlag for United States of America

asked on

Find the oldest record by date, and get that row, as well as records that aren't dupes

I'm trying to use the query below. What happens is that call_id can get many duplicates. I'm trying to get the latest call_id based in received_date of there are dupes. As well as getting any data that is not a dupe.

 
select received_date, call_id, COUNT(call_id)
from imp_WBDOC_data_myssa_callback
group by received_date, call_id
having COUNT(call_id) > 1
order by COUNT(call_id) des
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>I'm trying to get the latest call_id based in received_date of (of?) there are dupes.
>As well as getting any data that is not a dupe.
Looks like the above two statements are mutually exclusive.  Please provide us a sample data set and expected result of what you're trying to pull off here.
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Auerelio Vasquez

ASKER

Yes  im trying to get the latest call if there are dupes on the call_id based in the received date.

Also, most of the records don't have dupes, so I also want all rows where there are dupes, and only the record with  max received date, so that I'm only getting one row per call_id
Pony us up some sample data please.

Keep in mind that experts here cannot connect to your data source(s) and run queries, and all we have to go on to answer questions is the text provided by the asker, so what may be real obvious to you is not obvious to us.  Unless you give us some data to work with.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial