select t1.name,
       t1.phone,
       sum(decode(t2.send_status, 0, 1, 0)) 通知中,
       sum(decode(t2.send_status, 1, 1, 0)) 通知成功,
       sum(decode(t2.send_status, 2, 1, 0)) 通知失败,
       sum(1) 通知总次数
  from USERINFO t1, tempdial t2
 where t1.phone = t2.telno
 group by t1.name, t1.phone

解决方案 »

  1.   

    select t1.name,
           t1.phone,
           sum(decode(t2.send_status, 0, 1, 0)) 通知中,
           sum(decode(t2.send_status, 1, 1, 0)) 通知成功,
           sum(decode(t2.send_status, 2, 1, 0)) 通知失败,
           count(1) 通知总次数
      from USERINFO t1, tempdial t2
     where t1.phone = t2.telno(+)
     group by t1.name, t1.phone
      

  2.   

    楼主看看这样是否OK?
    select t1.name,
           t1.phone,
           count(select t.send_status from tempdial t where send_status='0') ,
           count(select t.send_status from tempdial t where send_status='1') ,
           count(select t.send_status from tempdial t where send_status='2') ,
           count(select t.send_status from tempdial t )
    from userinfo t1,tempdial t2
    where t1.phone=t2.telno
      

  3.   

    select t1.name,
           t1.phone,
           sum(decode(t2.send_status, 0, 1, 0)) 通知中,
           sum(decode(t2.send_status, 1, 1, 0)) 通知成功,
           sum(decode(t2.send_status, 2, 1, 0)) 通知失败,
           count(1) 通知总次数
      from USERINFO t1 left join tempdial t2
     on t1.phone = t2.telno
     group by t1.name, t1.phone