AS SELECT DDCLElement.Name
FROM DDCLElement 
WHERE 
 DDCLElement.DdsTypeId=25
 AND (DDCLElement.Id IN (SELECT * FROM #numeric_param_temp)) 
 AND DDCLElement.id not in (
 	select distinct DDCLElementChild.id
 	FROM DDCLElement 
	INNER JOIN DDCLValue ON DDCLElement.Id=DDCLValue.ElementId 
	INNER JOIN DDCLProperty ON DDCLValue.PropertyId=DDCLProperty.Id 
	INNER JOIN DDCLElement AS DDCLElementChild ON DDCLValue.ReferenceName=DDCLElementChild.Name 
		AND DDCLValue.ReferenceDdsTypeId=DDCLElementChild.DdsTypeId 
	WHERE DDCLElement.DdsTypeId=24 
	AND (DDCLValue.ReferenceDdsTypeId=25) 
	AND (DDCLProperty.Name='APPLICATIONS') 
	AND (DDCLElementChild.Id IN (SELECT * FROM #numeric_param_temp)) 
 )
ORDER BY DDCLElement.Name 