Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
642 B
2
Indexable
Never
select 
  * 
from 
  (
    select 
      count(*), 
      * 
    from 
      (
        select 
          ctry.name as country, 
          s.name as state, 
          cz.code as cresta, 
          c.name as county 
        from 
          county c 
          join country ctry on ctry.id = c.country_id 
          left outer join state s on s.id = c.state_id 
          left outer join cresta_zone cz on cz.id = c.cresta_zone_id
      ) as loc 
    group by 
      loc.country, 
      loc.state, 
      loc.cresta, 
      loc.county
  ) as dups 
where 
  dups.count > 1 
order by 
  dups.country, 
  dups.state, 
  dups.cresta, 
  dups.county