像这种很长的sql语句如何设置参数(按照我的表格设置),应该怎么改

image.png

select OrderDId,so.cMaker as 制单人,sos.cSCloser as 关闭人,sos.dbclosesystime as 关闭时间,SO.cCusCode AS 客户编码,c.cCusName as 客户名称 ,so.cSOCode as 销售订单,so.iverifystate ,

so.dDate as 订单日期,sos.cInvCode as 存货编码,i.cInvName as 存货名称,i.fGrossW as 毛重,sos.cFree1 as 色号 ,ie.cidefine10 as 是否定制,

sos.iQuantity as 订单数量,ISNULL(sos.foutquantity,0) as 累计出库数量 ,(sos.iQuantity-ISNULL(sos.foutquantity,0)) as 未出库数量 ,a.CreateDate as 生产日期,a.Qty as 生产数量,a.dDate as 入库日期,a.iQuantity as 入库数量,

 dis.cDLCode as 发货单号 ,dis.dDate as 发货日期,diss.iQuantity as 发货数量,

rd32.cCode as 出库单号,rd32.dDate as 出库日期,rds32.cBatch 系统出库批号,rds32.cDefine32 实际出库批号,rds32.iQuantity as 出库数量

 from  SO_SOMain so with (nolock) 

left join SO_SODetails sos with (nolock) on so.ID=sos.ID

left join (select OrderDId,sum(qty)as qty,sum(rd10.iQuantity)as iQuantity,

min(mom.CreateDate) as CreateDate ,max(rd10.ddate) as ddate

from  mom_orderdetail momo with  (nolock) 

left join  mom_order mom with (nolock) on mom.MoId=momo.MoId

left join  (select max(ddate) as ddate,cmocode,iMPoIds,sum(iQuantity) iQuantity

 from rdrecords10 rds10 with (nolock) 

 inner join  rdrecord10  rd10 with (nolock) on rd10.ID=rds10.ID

 group by cmocode,iMPoIds

 ) rd10 on rd10.cmocode=mom.MoCode and rd10.iMPoIds=momo.MoDId group by OrderDId) a on a.OrderDId=sos.iSOsID 

left join DispatchLists diss with (nolock) on diss.cSoCode=so.cSoCode  and diss.iSOsID=sos.iSOsID

left join DispatchList dis with (nolock) on dis.DLID=diss.DLID 

left join  rdrecords32 rds32 with (nolock) on  rds32.iDLsID=diss.iDLsID 

left join rdrecord32 rd32 with (nolock) on rd32.id=rds32.ID

left join Inventory  I with(nolock) on sos.cinvcode=i.cinvcode

left join Inventory_extradefine ie with(nolock) on ie.cInvCode=sos.cInvCode

left join Customer  c with (nolock) on c.cCusCode=so.cCusCode 

FineReport zhangjinrui 发布于 2021-10-19 11:05
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共4回答
最佳回答
0
b5184bLv3见习互助
发布于2021-10-19 14:18

看你的语句发货数量是diss.iQuantity

那么就是在你的where 后面加上diss.iQuantity='${发货数量}'

最佳回答
0
Z4u3z1Lv6专家互助
发布于2021-10-19 11:09(编辑于 2021-10-19 11:10)

眼拙,你表格有什么设置

通常情况在最后加

image.png

  • zhangjinrui zhangjinrui(提问者) 我的意思是,按照图中需要的字段当成参数进行筛选
    2021-10-19 11:24 
最佳回答
0
尛鬼Lv5中级互助
发布于2021-10-19 11:11

最简单的

with x as(

你的sql复制进来

)select * from x where .........

最佳回答
0
sysdbaLv5见习互助
发布于2021-10-19 14:29(编辑于 2021-10-19 14:30)

where 字段1=${p1} and 字段2 = ${p2} ...

  • 4关注人数
  • 493浏览人数
  • 最后回答于:2021-10-19 14:30
    请选择关闭问题的原因
    确定 取消
    返回顶部