AS SELECT     JCLPgm.PgmName, p.ProgramID, p.ProgramTypeID, p.Ancestor,
		Occurrences.StartRow, Occurrences.EndRow, Occurrences.StartCol, Occurrences.EndCol, Paths.PathStr, Ancestor.ProgramId
  FROM   JCLPgm INNER JOIN (SELECT DISTINCT Programs.ProgramID, Programs.Ancestor, ProgramAliases.AliasName AS ProgramName, Programs.OccurID, Programs.ProgramTypeID 
							from Programs 
							INNER JOIN ProgramAliases ON Programs.ProgramID = ProgramAliases.ProgramId) p 
							ON JCLPgm.PgmName = p.ProgramName		
                LEFT JOIN Occurrences on Occurrences.OccurID = p.OccurID
				LEFT JOIN Paths on paths.PathID = Occurrences.PathID
				LEFT JOIN (SELECT DISTINCT Programs.ProgramID, ProgramAliases.AliasName AS ProgramName, Programs.ProgramTypeID 
							from Programs 
							INNER JOIN ProgramAliases ON Programs.ProgramID = ProgramAliases.ProgramId) Ancestor 
							ON Ancestor.ProgramName = p.Ancestor  
  WHERE	(JCLPgm.PgmName IN (Select * from #string_param_temp)) 
  		AND	p.ProgramTypeID NOT IN (8, 13)
  		AND (Ancestor.ProgramTypeID IS NULL OR Ancestor.ProgramTypeID NOT IN (15, 16, 19))
