select A.id, A.AA1,b.coun from A,(selct id,count(*) coun from group by id) b where a.id=b.id

解决方案 »

  1.   

    方法一
    select A.id, A.AA1, A.AA2,count(*) 记录数 from A,B where B.id(+) = A.id ;方法二:(8i以上支持)
    select A.id, A.AA1, A.AA2, Count( select BB1 from B Where id = A.id ) from A, B;
      

  2.   

    我现在只选出了A在B中有对应ID的纪录,如果在B中没有与A对应的就取不出来,比如
    A:
    id AA1 AA21  22  33
    2  44  55B:
    id BB1 BB2
    1  xx  xxx
    1  xxy xxxxselect A.id, B.coun from A, (select id, count(*) coun from b group by id ) b where a.id = b.id只选出了
    A.id  B.coun
     1    2但是我希望的是A.id  B.coun
     1    2
     2    0请问我该怎样改?
      

  3.   

    哈哈!这个问题我还是两角的时候答的!现在都快三星了!select A.id, B.coun from A  left join (select id, count(*) coun from b group by id ) b  on  a.id = b.id
      

  4.   

    哦!原来是在oracle版呀!又来错了地方~~