AS SELECT DDCLElement.name as Application, DDCLValue.referencename as ElemName, 
                   count (DDCLProperty.name) as no, DDCLElement.DdsTypeId
from DDCLElement join DDCLProperty on DDCLElement.id = DDCLProperty.elementid
	 join DDCLValue on DDCLProperty.id=DDCLValue.propertyid
where DDCLElement.DdsTypeId in (25) and DDCLElement.islocal='false'
	 and DDCLValue.referenceddstypeid=7
	 AND DDCLValue.ValueTypeId in (2,4)
	 AND DDCLProperty.name = 'TASKS'
	 AND DDCLElement.id in (Select * from #numeric_param_temp)
group by DDCLElement.name, DDCLValue.referencename, DDCLElement.DdsTypeId
order by DDCLElement.name, DDCLValue.referencename
