Auerelio Vasquez
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_callb ack
group by received_date, call_id
having COUNT(call_id) > 1
order by COUNT(call_id) des
select received_date, call_id, COUNT(call_id)
from imp_WBDOC_data_myssa_callb
group by received_date, call_id
having COUNT(call_id) > 1
order by COUNT(call_id) des
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>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.