关闭

通过创建临时表得到所需要的辅助信息,最后边接主表

322人阅读 评论(0) 收藏 举报

select a.*,b.TheName ProductName,b.ConfigName,b.UnitName,c.TheName StorageName,d.StorPlaceName,
   b.BrandCode BrandCode,e.TheName BrandName,b.ModelCode ModelCode,f.TheName ModelName,
l.TheName DirectorName,m.TheName OperaterName,n.TheName DeptName
into #a from tbSelfOrderItem a
left outer join vDatumProduct b on a.ProductCode=b.TheCode and a.ProductSortCode=b.ProductSort
left outer join tbDatumStorage c on a.StorageCode=c.TheCode
Left outer join tbDatumStorageItem d on a.StorPlaceCode=d.StorPlaceCode and a.StorageCode=d.StorageCode
left outer join tbDatumProductBrand e on b.BrandCode=e.TheCode
left outer join tbDatumProductModel f on b.ModelCode=f.TheCode
left outer join tbSelfOrder g on g.BillNo=a.BillNo
left outer join vDatumEmployee l on g.DirectorCode=l.TheCode
left outer join vDatumEmployee m on g.OperaterCode=m.TheCode
left outer join vDatumDept n on g.DeptCode=n.TheCode

 

select a.*,b.TheName ShopName,b.ShopSortName ShopTypeName,b.CompanyName CompanyName,b.BelongAreaName BelongAreaName,
  c.TheName OrderModeName,d.TheName PayModeName,e.*
from tbSelfOrder a
left outer join vDatumShopArea b on a.ShopCode=b.TheCode
left outer join vSelfOrderMode c on a.OrderModeCode=c.TheCode
left outer join vSelfPayMode d on a.PayModeCode=d.TheCode
left outer join #a           e on a.BillNo= e.BillNo
where a.ShopCode in {{ShopGroup}} and e.StorageCode in {{StorageGroup}} {0}
drop table #a 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:473302次
    • 积分:6319
    • 等级:
    • 排名:第4011名
    • 原创:154篇
    • 转载:178篇
    • 译文:0篇
    • 评论:91条
    文章分类
    最新评论