表A:
字段:NO,S
NO-S
1 -3
2 -1
3 -2表B:
字段:NO,S,DETAIL
NO-DETAIL
1- 987
1- 988
1- 986
2- 10
3- 12
3- 111NO为1的下面有3个元素,这三个元素在表B中具体记录了分别是987,988,986。我现在要写一条SQL,要求表A中里的元素总数记录(3)减去表B中的对应详细记录(987,988,986)条数 也就是 3-count(DETAIL) 
等于0,小于0,大于0

解决方案 »

  1.   

    表B:
    字段:NO,S,DETAIL写错了,B中没有S这一字段。
      

  2.   

    select (select s from a where no=1) -
           (select count(*) from b where no=1) as tmp
    from dual
      

  3.   

    oracle这样,我知是可以的,在access里是好像不行。
      

  4.   

    select a.s-(select count(b.no) from b where b.no=a.no group by b.no) from a
    有条件后边可加上where a.no=1