Select t0.itemcode as 物料编码,t0.itemname as 物料名称,t0.codebars as 旧编码,t0.onhand as 库存量,t1.price as 采购价格 ,t2.price as 销售价格,(case when isnull(t2.price,0)=0 then 0 when isnull(t2.price,0)<>0 then (isnull(t2.price,0)-isnull(t1.price,0))/isnull(t2.price,0) end) as 毛利率 from oitm t0 left join (SELECT T0.[ItemCode], T1.[Price] FROM [dbo].[OITM] T0 INNER JOIN AIT1 T1 ON T0.ItemCode = T1.ItemCode WHERE T1.[PriceList] ='1' and t1.loginstanc= (SELECT max(t0.loginstanc) FROM AIT1 T0 where t0.itemcode=t1.itemcode)) t1 on t0.itemcode=t1.itemcode left join (SELECT T0.[ItemCode], T1.[Price] FROM [dbo].[OITM] T0 INNER JOIN AIT1 T1 ON T0.ItemCode = T1.ItemCode WHERE T1.[PriceList] ='2' and t1.loginstanc= (SELECT max(t0.loginstanc) FROM AIT1 T0 where t0.itemcode=t1.itemcode)) t2 on t0.itemcode=t2.itemcode where t0.cardcode=$[OPOR.CARDCODE]
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23503339/viewspace-680893/
,如需转载,请注明出处,否则将追究法律责任。