select decode(b.area_code,0951,'1银川',0952,'2石嘴山',0953,'3吴忠',0954,'4固原',0955,'5中卫',0)"地区",
sum(nvl(send_total_cnt,0)) "发送总条数",
sum(nvl(send_succes_cnt,0)) "发送成功总条数",
sum(nvl(send_fail_cnt,0)) "发送失败总条数",
sum(nvl(receive_total_cnt,0)) "接受总条数",
sum(nvl(receive_success_cnt,0)) "接受成功总条数",
sum(nvl(receive_fail_cnt,0)) "接受失败总条数",
sum(nvl(sett_in_fee,0))/100 "结入金额(元)",
sum(nvl(sett_out_fee,0))/100"结出金额(元)",
sum(nvl(sett_in_fee,0))/100+sum(nvl(sett_out_fee,0))/100 "差额(元)"
from (
select calling_area_code area_code,
called_brand_code,
calling_brand_code,
decode(calling_tsp_code,11,called_tsp_code,calling_tsp_code) sett_tsp,
case when sett_fee0 then sum(NUM_CDRS) end receive_total_cnt,
case when sett_fee>0 and 1=1 then sum(NUM_CDRS) end receive_success_cnt,
case when sett_fee>0 and 1=0 then sum(NUM_CDRS) end receive_fail_cnt,
case when sett_fee>0 then sum(sett_fee) end sett_in_fee,
case when sett_fee0 and product_id=190
and START_DATE>='&sBeginDate'||'00'--YYYYMMDD
and START_DATE22 or a.calling_brand_code22)
------ and a.called_brand_code22
-----and a.calling_brand_code22
and a.area_code(+)=b.area_code
group by decode(b.area_code,0951,'1银川',0952,'2石嘴山',0953,'3吴忠',0954,'4固原',0955,'5中卫',0)
order by decode(b.area_code,0951,'1银川',0952,'2石嘴山',0953,'3吴忠',0954,'4固原',0955,'5中卫',0)
如上面红色标注处语句and (a.called_brand_code22 or a.calling_brand_code22 ),结果查询发现这个or根本没效果,没这个语句查询结果一样!
而单独执行我注释掉的兰色处,语句为and a.called_brand_code22 却可以查出记录,
或者单独执行我注释掉的棕色处,语句为and a.calling_brand_code22 也可以查到结果,
说明or语句起不到效果,请问一下,问题出在哪里,之前我有把这个or都写到子查询里面去了也不行,现在写在外面也不行,奇怪,奇各位高手帮忙看看,谢谢!
[ 本帖最后由 wabjtam123 于 2008-9-24 18:12 编辑 ]
|