Select * From(
Select
ORG.FNAME as 库存组织,
T2.FNUMBER as 物料编码,
T3.FNAME as 物料名称,
T3.FSPECIFICATION as 规格型号,
T6.FNAME as 单位,
Convert(decimal (23,4),T1.FBASEQTY) as 可用库存,
T8.FNAME as 仓位名称,
T9.FNUMBER as 仓位编码,
T4.FNAME as 所在仓库,
T5.FNUMBER as 批号
From T_STK_INVENTORY T1
Inner Join T_ORG_Organizations_L ORG ON T1.FSTOCKORGID=ORG.FORGID
Inner Join T_BD_MATERIAL T2 ON T1.FMATERIALID=T2.FMATERIALID
Inner Join T_BD_MATERIAL_L T3 ON T1.FMATERIALID=T3.FMATERIALID
Inner Join T_BD_STOCK_L T4 ON T4.FSTOCKID=T1.FSTOCKID
Inner Join T_BD_LOTMASTER T5 ON T1.FLOT=T5.FLOTID
Inner Join T_BD_UNIT_L T6 ON T1.FBASEUNITID=T6.FUNITID And T6.FLOCALEID=2052
Left Join T_BAS_FLEXVALUESDETAIL T7 ON T7.FID=T1.FSTOCKLOCID--仓位关联ID
Left Join T_BAS_FLEXVALUESENTRY_L T8 ON T8.FENTRYID=T7.FF100001--关联仓位名称
Left Join T_BAS_FLEXVALUESENTRY T9 ON T9.FENTRYID=T7.FF100001--关联仓位编码
Where T1.FBASEQTY !=0 --可用库存不等于0
) List Where 物料编码='物料编码'