日期:2014-05-18 浏览次数:20603 次
CREATE PROCEDURE b_test @YCLRKH varchar(10),@GCRCLMLH varchar(15),@CKDM int,@FPHM varchar(10) AS begin select ltrim(a.YCLRKH)YCLRKH,a.SL,a.ZZL,a.JE,sum(a.JE)as CJE, a.GCRCLMLH,a.CKDM,b.GCMC,b.FPHM as FPHM ,b.FPJE, c.LJMC,c.TZCC,c.CLPH,c.JH from BCPRKTZB a left join JGCHSJB b on a.BCPSLDID=b.BCPSLDID left join CLB c on a.RKXH=C.RKXH where (a.YCLRKH like '%' + @YCLRKH+ '%' or @YCLRKH='') and (a.GCRCLMLH like '%' + @GCRCLMLH+ '%' or @GCRCLMLH='') and (b.FPHM like '%' + @FPHM+ '%' or @FPHM='') and(a.CKDM = +convert(varchar(10),@CKDM) or @CKDM<0 ) union all select '合计:','','',sum(a.JE), sum(a.GCRCLMLH),'','','' ,'', '','','','' from BCPRKTZB a left join JGCHSJB b on a.BCPSLDID=b.BCPSLDID left join CLB c on a.RKXH=C.RKXH where (a.YCLRKH like '%' + @YCLRKH+ '%' or @YCLRKH='') and (a.GCRCLMLH like '%' + @GCRCLMLH+ '%' or @GCRCLMLH='') and (b.FPHM like '%' + @FPHM+ '%' or @FPHM='') and(a.CKDM = +convert(varchar(10),@CKDM) or @CKDM<0 ) end GO