CREATE VIEW [dbo].[RPMViewUofM]
AS
SELECT dbo.IV40202.UOMSCHDL, dbo.IV40202.UOFM, dbo.IV40202.SEQNUMBR, CAST(CASE WHEN RTRIM(dbo.IV40201.BASEUOFM) = RTRIM(dbo.IV40202.UOFM) THEN 1 ELSE 0 END AS INT) AS ISBASE, 
	dbo.IV40201.UMSCHDSC,dbo.IV40202.QTYBSUOM, RTRIM(LTRIM(dbo.IV40202.UOMSCHDL)) + '-' + CAST(dbo.IV40202.SEQNUMBR AS VARCHAR) AS ERPID
FROM dbo.IV40202 
	LEFT JOIN dbo.IV40201 ON dbo.IV40202.UOMSCHDL = dbo.IV40201.UOMSCHDL
WHERE EQUIVUOM = BASEUOFM
