Select count / duplicates

后端 未结 5 841
悲&欢浪女
悲&欢浪女 2021-01-18 00:53

I have a table with all U.S. zip codes. each row contains the city and state name for the zip code. I\'m trying to get a list of cities that show up in multiple states. This

5条回答
  •  鱼传尺愫
    2021-01-18 01:08

    First group on state and city, then group the result on city:

    select City
    from (
      select State, City
      from ZipCode
      group by State, City
    ) x
    group by City
    having count(*) > 1
    

提交回复
热议问题