select accessno,
       (select sum(xp) from t1 where accessno=tt.accessno) as xp,
       (select sum(sp) from t1 where accessno=tt.accessno) as sp,
       optpye,
       fail,
       success
  from t1 tt

解决方案 »

  1.   

    select accessno,
           t2.xp,
           t2.sp,
           optpye,
           fail,
           success
      from t1,(select accessno,sum(xp) xp,sum(sp) from t1 group by accessno) t2
    where t1.accessno=t2.accessno
      

  2.   

    以后2种都访问多次数据库。应该用分析函数我给你个示意
    sum(xp) over (partition by no order by no 
    rows between unbounded preceding and unbounded following)