AS SELECT ProgramAliases.AliasName AS ProgramName, 
              SCLSystemFiles.Name AS [File Name], 
              Statements.Description AS [Statement type], 
              Count(Distinct OccurrencesStmt.OccurID) AS Expr1, 
              '', (''+ProgramAliases.AliasName) as k 
FROM StatementReference INNER JOIN OccurrencesStmt ON StatementReference.OccurID = OccurrencesStmt.OccurID
     INNER JOIN Files ON StatementReference.ResourceID = Files.FileID
     INNER JOIN SCLSystemFiles on SCLSystemFiles.OccurId = Files.OccurID and SCLSystemFiles.fileId = Files.FileID
     INNER JOIN ProgramAliases ON OccurrencesStmt.ProgID = ProgramAliases.ProgramID and ProgramAliases.AliasType = 0
     INNER JOIN Statements ON StatementReference.StatementType = Statements.StatementType 
WHERE (
	((StatementReference.ResourceType)=9) 
	AND (ProgramAliases.ProgramID in (Select * from #numeric_param_temp))
	AND (Files.TypeCode <> 32 OR Files.TypeCode IS NULL)
	AND SCLSystemFiles.Name is not null
) 
GROUP BY ProgramAliases.AliasName, SCLSystemFiles.Name, Statements.Description 
ORDER BY k, SCLSystemFiles.Name