标签:
代码如下
select distinct G.* ,(select BUSINESS_NAME from BusinessInfo where BusinessInfo.BUSINESS_BID=G.G_BUSINESS_ID) as BUSINESS_NAME ,(select sum(StockGNum) from StockDetail where StockDetail.StockGID =G.G_ID) as StockGNum ,(select sum(StockRemovalGNum) from StockRemovalDetail where StockRemovalDetail.StockRemovalGID =G.G_ID) as StockRemovalGNum ,T.COMMUNITYID ,case when GNumber is null then 0 else DA.GNumber end as GNumber -- 判断为空 from B_GoodsInfo G left join B_Goods_Type T on G.G_BUSINESS_ID = T.T_BUSINESS_ID left join BusinessInfo B on G.G_BUSINESS_ID = B.BUSINESS_BID left join (select * from DiningCarApplyDetail where ApplyForDate = CONVERT(varchar(100), GETDATE(), 23)) DA on DA.GID=G.G_ID where T.COMMUNITYID = ‘43450BD834E54247A187DD0186E96240‘ and B.BUSINESS_Type=‘001‘
标签:
原文地址:http://www.cnblogs.com/nele/p/5045641.html