CREATE PROC [dbo].[sp_GetSurfaceFieldAggregatePASSED]
( 
	@surfaceItemId INT
	,@actionValue VARCHAR(255)
)
AS

SELECT	COUNT(1)
FROM	pal_SurfaceField F
		JOIN pal_SurfaceFieldData D
			ON D.surfaceFieldID = F.recId
WHERE	D.surfaceItemId = @surfaceItemId
		AND F.recId IN (SELECT splitdata FROM SplitString(@actionValue,'|'))
		AND 50 <= CASE F.surfaceFieldTypeId 
					WHEN 4
					THEN D.surfaceFieldValueNum
					WHEN 5
					THEN D.surfaceFieldValueDecimal
					END

GO


