I have a query that is providing the correct data to me but if there are multiple records in the tuitionSubmission table for the same empID, it shows duplicate results (as expected).
I am trying to use a distinct selector on this query on A.[empID]
Below is my Query:
SELECT A.[empID],
               A.[id],
               A.[empGradDate],
               A.[status],
               A.[reimbursementDate],
               A.[firstName],
               A.[lastName],
               A.[businessTitle] AS department,
               B.[SupEmpID],
               B.[ntid] AS empNTID,
               B.[GeoLocationDesc] AS location,
               C.[FirstName] + ' ' + C.[LastName] AS supervisor,
               C.[ntid] AS supNTID,
               C.[SupEmpID],
               D.[FirstName] + ' ' + D.[LastName] AS manager,
               D.[ntid] AS managerNTID
        FROM   tuitionSubmissions AS A
               INNER JOIN
               empTable AS B
               ON A.[empID] = B.[EmpID]
               INNER JOIN
               empTable AS C
               ON C.[empID] = B.[SupEmpID]
               INNER JOIN
               empTable AS D
               ON D.[empID] = C.[SupEmpID]
        WHERE
            B.[EmpID]= COALESCE(@ntid, B.[EmpID]) OR
            B.[SupEmpID]= COALESCE(@supervisor, B.[SupEmpID]) OR
            C.[SupEmpID]= COALESCE(@manager, C.[SupEmpID]) OR
            A.[EmpID]= COALESCE(@empName, C.[EmpID]) OR
            B.[GeoLocationDesc]= COALESCE(@theLocation, B.[GeoLocationDesc]) OR
            B.[SiloDesc]= COALESCE(@department, B.[SiloDesc])
        FOR    XML PATH ('details'), TYPE, ELEMENTS, ROOT ('root');
The table tuitionSubmissions can contain multiple records for the same user (same empID) but I only want to show one of them
 
     
     
    