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

解决方案 »

  1.   

    select a.aa,a.bb,a.cc ,(select count(b.aa) from b where b.aa = a.aa)
    from a
      

  2.   

    select a.aa,a.bb,a.cc, count(b.aa)
    from a left join b on a.aa =b.aa
    group by a.aa,a.bb,a.cc
      

  3.   

    select B.id,count(*) as num from A,B where A.ID=*B.id group by A.ID
      

  4.   

    select A.[ID],name,B.Num from #A A,(select ID,count(ID) as Num from #B group by ID) B
    where A.ID=B.ID
      

  5.   

    select A.ID,A.name,c.Count
    from A left join
      (select B.ID,B.name,count(*) as Count from B group by B.ID,B.name)c
         on (A.ID = c.ID and A.name = c.name)
      

  6.   

    select A.ID,A.Name,(select count(B.ID) from B where B.ID = A.ID)
    from A
      

  7.   

    select a.id,name,count(b.id) from a inner join b on a.id=b.id