	SELECT 
		T0.FMASTERID
		,T0.FMATERIALID
		,T0.FNUMBER
		,ISNULL(T1.STOCKQTY,0) AS FSTOCKQTY
		,T0.FUSEORGID
		,t2_l.FNAME
	FROM 
		T_BD_MATERIAL T0
		LEFT JOIN T_BD_MATERIALPRODUCE T0P ON T0P.FMATERIALID = T0.FMATERIALID 
		LEFT JOIN (
		SELECT 
			T1.FMATERIALID
			
			,t1.FSTOCKORGID
			,SUM(T1.FBASEQTY) AS STOCKQTY
		FROM
			T_STK_INVENTORY T1
		GROUP BY 
			T1.FMATERIALID,
			t1.FSTOCKORGID
		) T1 ON T0.FMASTERID = T1.FMATERIALID --物料id
		AND t0.FUSEORGID = t1.FSTOCKORGID --使用组织
		LEFT JOIN T_ORG_ORGANIZATIONS_L t2_l on t2_l.FORGID = t0.FUSEORGID AND t2_l.FLOCALEID =2052
	WHERE
		T0.FDOCUMENTSTATUS = 'C' 
		AND t0.FNUMBER = '1.01.003' --物料编码
	ORDER BY T0.FMATERIALID