日期:2014-05-17  浏览次数:20738 次

sql做连续减法怎么办?
SQL code
(isnull((select sum(cq_dinner) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='04' and cq_ctime<=:etime),0) -
isnull((select sum(cq_dinner) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='03' and cq_ctime<=:etime),0) ) as totaldinner

//通过
(isnull((select sum(cq_dinner) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='04' and cq_ctime<=:etime),0) -
isnull((select sum(cq_dinner) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='05' and cq_ctime<=:etime),0) -
isnull((select sum(cq_dinner) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='03' and cq_ctime<=:etime),0) ) as totaldinner-
//通不过




------解决方案--------------------
你的第二段Code, as totaldinner 后多了一个 减号, 去掉再试试。