Remove duplicates based on a criteria

NickOnTheNet

New member
Local time
Today, 08:09
Joined
Sep 2, 2020
Messages
4
Hi all,
can someone help me with this please?

I need to remove any duplicates from Query: qu_combined_sp which have the highest Rank (highlighted).
The result I need is in Query: qu_combined_sp_result

query.JPG


Thanks for your time!!

Regards... Nick
 
Hi Nick,

What is the logic we can use to determine a duplicate?
 
probably better to do it all in one query rather than chaining queries together, but perhaps something like

Code:
SELECT *
FROM  qu_combined_sp  A
WHERE Rank=(SELECT min(Rank) FROM  qu_combined_sp WHERE RGR=A.RGR)
 
probably better to do it all in one query rather than chaining queries together, but perhaps something like

Code:
SELECT *
FROM  qu_combined_sp  A
WHERE Rank=(SELECT min(Rank) FROM  qu_combined_sp WHERE RGR=A.RGR)

Perfect!! Thank you!!
Another day where I learned something (y) (y)
 
a faster way would be

SELECT A.*
FROM qu_combined_sp A INNER JOIN (SELECT RGR, min(Rank) as mRank FROM qu_combined_sp GROUP BY RGR) B ON A.RGR=B.RGR AND A.Rank=B.mRank
 

Users who are viewing this thread

Back
Top Bottom