
/****** Object:  UserDefinedFunction [dbo].[fn_getInTransitNum]    Script Date: 2021-01-08 20:57:31 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



 
CREATE FUNCTION [dbo].[fn_getInTransitNum](@PFormMId int)  
RETURNS float   
AS   


BEGIN  
    DECLARE @ret float,@firstProcessNum float,@totalProcessNum float	
	set @ret=0
	select @totalProcessNum=sum(MakingNum) from ProProcess where PFormMId=@PFormMId
	select top 1 @firstProcessNum=MakingNum from ProProcess where PFormMId=@PFormMId  Order By ProcessNo ASC
	set @ret=@totalProcessNum-@firstProcessNum
    RETURN @ret
END; 
GO


