select s.phone_number,s2.brand_desc,s1.subs_time
from cdr_gsm s,tb_subs s1,code_brand s2
where to_char(s.call_time,'YYYY-MM-DD')=substr(to_char(sysdate,'yyyy-mm-dd'),0,7)
and s.roaming_type='国际' and s1.phone_number=s.phone_number and s1.brand(+)=s2.brand_id
长途费用、漫游费用、主叫费用、被叫费用
本地通话次数及费用
自己去计算吧!

解决方案 »

  1.   

    select *
    from 
    (select s.phone_number,s2.brand_desc,s1.subs_time,s.call_cost
    from cdr_gsm s,tb_subs s1,code_brand s2,adr_sms s3
    where to_char(s.call_time,'YYYY-MM-DD')=substr(to_char(sysdate,'yyyy-mm-dd'),0,7)
    and s.roaming_type='国际' and s1.phone_number=s.phone_number and s1.brand(+)=s2.brand_id) aa
    ,
    (select s4.phone_number,count(*),sum(sms_cost) from adr_sms s4 group by s4.phone_number) ss 
    where aa.phone_number=ss.phone_number
    短信次数费用!
      

  2.   

    最好给出你的测试数据。   建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。