SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


ALTER VIEW  [dbo].[hw_scdd_select] 
AS
SELECT wl.FMATERIALID, rwds.FUNITID, rwds.FENTRYID AS FID, rwd.FBILLNO AS FNUMBER, xsd.FBILLNO AS FXSNO, 
                wl.FNUMBER AS FCPNO, wls.FNAME AS FCPNM, wls.FSPECIFICATION, 
                dw.FNUMBER AS FDWNM, rwds.FQTY + rwds.F_BDS - rwds.F_YSCS - rwds.F_GRJJS AS FWSCS, 
                rwds.FQTY + rwds.F_BDS AS FQTY
FROM      T_PRD_MO AS rwd INNER JOIN
                T_PRD_MOENTRY AS rwds ON rwd.FID = rwds.FID INNER JOIN
                T_BD_MATERIAL AS wl ON rwds.FMATERIALID = wl.FMATERIALID INNER JOIN
                T_BD_MATERIAL_L AS wls ON wl.FMATERIALID = wls.FMATERIALID left outer JOIN
                T_SAL_ORDER AS xsd ON rwds.FSALEORDERID = xsd.FID INNER JOIN
                T_BD_UNIT AS dw ON rwds.FUNITID = dw.FUNITID
WHERE   (rwd.FDOCUMENTSTATUS = 'C')
	AND CONVERT(int,CONVERT(varchar(4),rwd.FDATE,112)) = 2025

GO