@depid@ varchar(50), @jhleibie@ varchar(50), @stime@ datetime, @ltime@ datetime as
declare @dep varchar(50),@leibie varchar(50) set @dep=@depid@ set @leibie=@jhleibie@ select d.fname as 填报单位, j.fname as 计划类别, i.fname as 物资名称, i.fmodel as 规格 , t1.fxuyongshuliang as 数量, t1.fyusuandanjia as 预算单价, t1.fyusuanjine as 预算金额, t.fdate as 填报日期, t.fuser1 as 一审人, t.fdate2 as 一审时间, t.fuser2 as 二审人, t.fdate3 as 二审时间, t.fuser3 as 三审人, t.fdate4 as 三审时间, t.fuser4 as 四审人, t.fdate5 as 四审时间, t.fuser5 as 五审人, t.fdate6 as 五审时间, t.fuser6 as 六审人, t.fdate7 as 六审时间, t.fuser7 as 七审人, t.fdate8 as 七审时间, t.fuser8 as 八审人, t.fdate9 as 八审时间 from t_BOS200000000entry2 t1 left join t_BOS200000000 t on t1.fid=t.fid left join t_icitem i on t1.fwuliao=i.fitemid left join t_department d on t.fbase=d.fitemid left join t_BOS200000005 j on t.fbase5=j.fid
where t.fid=t1.fid and t1.fwuliao=i.fitemid and t.fbase=d.fitemid and t.fbase5=j.fid and (@dep='' or d.fname = @dep) and (@leibie='' or j.fname = @leibie) and t.fdate>=@stime@ and t.fdate<=@ltime@ GO 这个能运行,但有这么个问题,fuser1,fuser2……现在是用户的代码, 需要显示姓名,跟t_user表是这样关联的 select fname from _t_user u where u.fuserid=fuser1` 这个过程应该怎么改写下,谢谢