AS SELECT     dbo.ProgramAliases.ProgramID, dbo.ProgramAliases.AliasName AS ProgramName, dbo.Paths.PathStr, dbo.Occurrences.StartRow, dbo.Variables.IsCopy
FROM         dbo.Variables INNER JOIN
                      dbo.Occurrences ON dbo.Variables.OccurID = dbo.Occurrences.OccurID INNER JOIN
                      dbo.Paths ON dbo.Occurrences.PathID = dbo.Paths.PathID INNER JOIN
                      dbo.Programs ON dbo.Variables.ProgIDReference = dbo.Programs.ProgramID INNER JOIN
                      dbo.ProgramAliases ON dbo.ProgramAliases.ProgramId = dbo.Programs.ProgramID 
                        AND dbo.ProgramAliases.AliasType = 0
WHERE     (NOT (dbo.Variables.VarID IN
                          (SELECT     FollowedByVarId
                            FROM          dbo.SourceComments
                            WHERE      (NOT (FollowedByVarId IS NULL))))) AND (dbo.Variables.iLevel = 1) AND (dbo.Programs.ProgramTypeID = 1)
ORDER BY dbo.ProgramAliases.AliasName, dbo.Paths.PathStr, dbo.Occurrences.StartRow 