select
isnull(d.name,'') as buMenName
,isnull(d.dep,'') as buMenBianHao
,isnull(mf.MO_NO,'') AS osNo
,isnull(CONVERT(varchar(100), mf.MO_DD, 23),'') AS osDd-------单子的时间
,CONVERT(varchar(100),IsNULL(QTY,0)-IsNULL(QTY_FIN,0)) AS sumQTY ---注意,表头是没有重复的
from
mf_mo mf
left join my_wh myw on mf.wh=myw.wh
left join DEPT d on d.dep=mf.dep
where
--subString(mf.mo_no,1,2)='MO'
--and
mf.CLOSE_ID != 'T' and
mf.CF_ID != 'F'
AND IsNULL(QTY,0)-IsNULL(QTY_FIN,0)>0
and
mf.wh=(
case when #{cangKuNum}='' then mf.wh
when #{cangKuNum}='undefined' then mf.wh
when #{cangKuNum} is null then mf.wh
else #{cangKuNum}
end
)
ORDER BY mf.MO_DD DESC