select a.sf as 身份,城市数=(select count(*) from city where sf=a.id) from sf a
where sf in('浙江','上海','北京')

解决方案 »

  1.   

    select a.sf as 省份,count(b.city) from sf a,city b where a.sf=b.sf group by a.sf
      

  2.   

    select a.sf as 省份,count(b.city) from sf a,city b where a.id=b.sf group by a.sf
      

  3.   

    select b.sf,a.num from (select sf,num=count(sf) from city group by sf) a
    left join sf b on a.sf=b.id
      

  4.   

    select a.sf as 省份,count(b.city) as 城市数 from sf a,
    (select count(city),sf from city group by sf)b
    where a.sf=b.sf
      

  5.   

    select a.sf ,count(b.sf) from sf a ,city b where a.id=b.sf group by a.sf
      

  6.   

    select a.sf province, count(c.city) as n from sf a join  city c on a.id=c.sf group by c.sf