两个表之间的连续呢? 比如要加:
select isnull(sum(e.TotalMoney),0)-isnull(sum(o.TotalMoney),0)
from WHM_EnterBill E,WHM_OutBill O
where e.acceptdate<='2006-1-1' and o.POSTDATE<='2006-1-1'
and e.id=o.id --这里要添加限定的
select isnull(sum(e.TotalMoney),0)-isnull(sum(o.TotalMoney),0)
from WHM_EnterBill E,WHM_OutBill O
where e.acceptdate<='2006-1-1' and o.POSTDATE<='2006-1-1'
and e.id=o.id --这里要添加限定的
(select isnull(sum(e.TotalMoney),0) from WHM_EnterBill e where e.acceptdate<='2006-1-1') a
inner join
(select isnull(sum(o.TotalMoney),0) from WHM_OutBill o where o.POSTDATE<='2006-1-1') b
) c
我本来以为这样可以的 hoho
可以这样
select
(select isnull(sum(e.TotalMoney),0) from WHM_EnterBill e where e.acceptdate<='2006-1-1')
-
(select isnull(sum(o.TotalMoney),0) from WHM_OutBill o where o.POSTDATE<='2006-1-1') b
) c
WHM_EnterBill表中acceptdate<='2006-1-1'的记录 和
WHM_OutBill表中POSTDATE<='2006-1-1'的记录 进行交叉联合。
然后对新的结果集进行sum运算。
from WHM_EnterBill
where acceptdate <='2006-1-1') -
(select IsNull(sum(IsNull(sz,0)),0)
from WHM_OutBill
where POSTDATE<='2006-1-1')