Skip to content

Instantly share code, notes, and snippets.

@oharsta
Created August 17, 2023 09:30
Show Gist options
  • Save oharsta/a9b2503392ccf08e7576c8ec0cef1eb7 to your computer and use it in GitHub Desktop.
Save oharsta/a9b2503392ccf08e7576c8ec0cef1eb7 to your computer and use it in GitHub Desktop.
Find duplicates based on multiple columns
select s.id, t.*
from service_groups s
join (
select short_name, service_id, count(*) as qty
from service_groups
group by short_name, service_id
having count(*) > 1
) t on s.short_name = t.short_name and s.service_id = t.service_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment