Untitled

 avatar
unknown
plain_text
2 years ago
642 B
5
Indexable
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
Editor is loading...