日期:2014-05-17  浏览次数:20851 次

问sql问题
select rownum rowindex,
        count(*) js,
       a.cpid,
       a.hssl,
       TO_CHAR(a.dj, 'FM99999999990.00') dj,
       (sum(nvl(a.sl, 0)) || ' ' || a.jldw) sljl,
       TO_CHAR(sum(a.je), 'FM99999999990.00') zh,
       (a.product || '  ' || TO_CHAR(a.hssl, 'FM99999999990.00') || ' ' ||a.HSDW) product, 
       a.bz,
       a.je
  from (SELECT count(*) js,
               a.sfdjid,
               a.cpid,
               b.CPBM,
               b.PRODUCT,
               
               b.JLDW,
               1,
               b.HSDW,
               a.sl,
               a.hssl,
               a.dj,
               (a.sl * a.dj * count(*)) je,
               a.bz
              
               
          FROM kc_sfdjmx a
          JOIN vw_kc_dm_dmsx b
            ON a.cpid = b.CPID
         WHERE a.sfdjid = '" + sfdjid + "'
         group by a.cpid,
                  a.sfdjid,
                  a.cpid,
                  b.CPBM,
                  b.PRODUCT,
                  b.bjfs,
                  b.JLDW,
                  b.HSDW,
                  a.hssl,
 &