select count(*) as cn from (select t1.B,t2.D 
  from t1,t2 where t1.b=t2.b) as A 
 group by D

解决方案 »

  1.   

    select t2.D,count(t1.B) from t1,t2 where t1.B=t2.B group by t1.D
      

  2.   

    select 
        t2.D,
        count(t1.B) 
    from 
        t1
    inner join
        t2 
    on 
        t1.B=t2.B 
    group by 
        t2.D
      

  3.   

    select t2.D,count(t1.B) from t1,t2 where t1.B=t2.B group by t2.D
      

  4.   

    select t1.B,t2.D where t1.b=t2.b group by t2.d
      

  5.   

    select count(M.*) from(select t1.B,t2.D from t1,t2 where t1.b=t2.b) as M group by M.D
      

  6.   

    加个group by t2.d
    不就可以了,不明白楼主为什么要“select count(*) ”如果要得到没组的条数:
    select t1.B,t2.D,count(t1.b) where t1.b=t2.b group by t2.d
      

  7.   

    加个group by t2.d不就可以了如果要得到分组条数:select t1.B,t2.D,count(t1.b) where t1.b=t2.b group by t2.d