select isnull(F1,'合计'),sum(F2) F2
from ( select a.F1,sum(a.F2) F2 from B,A 
where b.id=a.id group by F1
)DERIVEDTBL
group by F1 with rollup

解决方案 »

  1.   

    这个子查询中好像 b 表没有用处,是不是其中的 a.F2 应该换成 b.F2:select a.F1,sum(a.F2) F2 from B,A 
    where b.id=a.id group by F1
      

  2.   

    就算只有B表也不行啊
    select isnull(F1,'合计'),sum(F2) F2
    from ( select F1,sum(F2) F2 from B group by F1
    )DERIVEDTBL
    group by F1 with rollup
      

  3.   

    F1,F2
    A  1
    B  2
    A  3
    B  4