select b.bmh as b,a.pycj as d41,b.pycj as d42,c.pycj as d43,a.pycj+b.pycj+c.pycj as zcj from t_1_a_41_pyjd a,t_1_a_42_pyjd b,t_1_a_43_pyjd c where a.bmh=b.bmh,b.bmh=c.bmh;
其中:
t_1_a_41_pyjd,t_1_a_42_pyjd,t_1_a_43_pyjd是三个表。我想把三个pycj加在一起啊。 

解决方案 »

  1.   


    select b.bmh,a.pycj,b.pycj,c.pycj,a.pycj+b.pycj+c.pycj as zcj from 
    t_1_a_41_pyjd a,
    t_1_a_42_pyjd b,
    t_1_a_43_pyjd c 
    where a.bmh=b.bmh,b.bmh=c.bmh; 
      

  2.   

    把列的别名去掉就行了select b.bmh,a.pycj,b.pycj,c.pycj,a.pycj+b.pycj+c.pycj as zcj from 
    t_1_a_41_pyjd a,
    t_1_a_42_pyjd b,
    t_1_a_43_pyjd c 
    where a.bmh=b.bmh and b.bmh=c.bmh;--忘记and了。 
      

  3.   

    select b.bmh,a.pycj,b.pycj,c.pycj,nvl(a.pycj, 0)+ nvl(b.pycj, 0)+nvl(c.pycj, 0) /*如果有null值,相加为null*/ as zcj from 
    t_1_a_41_pyjd a,
    t_1_a_42_pyjd b,
    t_1_a_43_pyjd c 
    where a.bmh=b.bmh and b.bmh=c.bmh; --,改成and 了