AS SELECT DDCLValue.referencename as FileName, DDCLElement.name as ElementName, 
	  DDCLProperty.name as PropertyName, 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 (27,28) and DDCLElement.islocal='false'
	 and DDCLValue.referenceddstypeid=12
	 AND DDCLValue.ValueTypeId in (2,4)
group by DDCLValue.referencename, DDCLElement.name, DDCLProperty.name, DDCLElement.DdsTypeId
order by DDCLValue.referencename, DDCLElement.name, DDCLProperty.name 