大家帮小弟我看上这个SQL语句!
大家帮我看下这个SQL语句!!
放在Query组件里的,D5,通不过!主要是用了连续的减法,要怎么改?
下面是通过的
- SQL code
select *, isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=1 and ca_ctime<=:etime) ,0) as totals, isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=0 and ca_ctime<=:etime) ,0) as totalc, (isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=1 and ca_ctime<=:etime),0)- isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=0 and ca_ctime<=:etime),0)) as totalb, isnull((select sum(sp_money) from cjf_salecardpay where sp_caccno=a.c_accno and sp_ctime<=:etime),0) as totalp, isnull((select sum(cp_money) from cjf_card_consumepay where cp_cardacc=a.c_accno and cp_ctime<=:etime),0) as totalu, (isnull((select sum(jf_money) from cjf_card_jifen where jf_cardacc=a.c_accno and jf_type=1 and jf_ctime<=:etime),0) - isnull((select sum(jf_money) from cjf_card_jifen where jf_cardacc=a.c_accno and jf_type=0 and jf_ctime<=:etime),0) ) as totalbjf, [color=#FF0000](isnull((select sum(cq_breakfast) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='04' and cq_ctime<=:etime),0) - isnull((select sum(cq_breakfast) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='01' and cq_ctime<=:etime),0) - isnull((select sum(cq_breakfast) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='05' and cq_ctime<=:etime),0)) as totalbreakfast, (isnull((select sum(cq_lunch) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='04' and cq_ctime<=:etime),0) - isnull((select sum(cq_lunch) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='02' and cq_ctime<=:etime),0) - isnull((select sum(cq_lunch) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='05' and cq_ctime<=:etime),0)) as totallunch, (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) - isnull((select sum(cq_dinner) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='05' and cq_ctime<=:etime),0)) as totaldinner[/color]from cjf_card a where c_ctime<=:etime and (1=:allflag or c_flag=:c_flag) order by c_cardno
放在Query组件里的,D5,通不过!主要是用了连续的减法,要怎么改?
下面是通过的
- SQL code
select *, isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=1 and ca_ctime<=:etime) ,0) as totals, isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=0 and ca_ctime<=:etime) ,0) as totalc, (isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=1 and ca_ctime<=:etime),0)- isnull((select sum(ca_money) from cjf_card_account where ca_cardacc=a.c_accno and ca_type=0 and ca_ctime<=:etime),0)) as totalb, isnull((select sum(sp_money) from cjf_salecardpay where sp_caccno=a.c_accno and sp_ctime<=:etime),0) as totalp, isnull((select sum(cp_money) from cjf_card_consumepay where cp_cardacc=a.c_accno and cp_ctime<=:etime),0) as totalu, (isnull((select sum(jf_money) from cjf_card_jifen where jf_cardacc=a.c_accno and jf_type=1 and jf_ctime<=:etime),0) - isnull((select sum(jf_money) from cjf_card_jifen where jf_cardacc=a.c_accno and jf_type=0 and jf_ctime<=:etime),0) ) as totalbjf, [color=#FF0000](isnull((select sum(cq_breakfast) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='04' and cq_ctime<=:etime),0) - isnull((select sum(cq_breakfast) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='01' and cq_ctime<=:etime),0) as totalbreakfast, (isnull((select sum(cq_lunch) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='04' and cq_ctime<=:etime),0) - isnull((select sum(cq_lunch) from cjf_card_dzcq where cq_cardno=a.c_incode and cq_type='02' and cq_ctime<=:etime),0)as totallunch, (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[/color]from cjf_card a where c_ctime<=:etime and (1=:allflag or c_flag=:c_flag) order by c_cardno