Q:

Selecting values without duplicates when conditions meet

I have two tables joining on basis of common one between them and I need one columns each from two tables in the output, when a case condition meets. I see both the columns return their respective records but I see a problem. I see duplicates and I am not sure what is that I am doing wrong here. Attached is the picture with more details. 

A:

You'll need to use aggregation functions and GROUP BY:
SELECT  d.docnum DocNumber,
        e.empnam EmpName,
        MAX(CASE
                WHEN t.EmpTypID = '4' THEN e.EmpID
            END) EmpID,
        MAX(CASE
                WHEN t.EmpTypID = '2' THEN e.EmpID
            END) EmpAltID
FROM DocTable d
LEFT JOIN EmpTable e
    ON d.docnum = e.docnum
LEFT JOIN TypeTable t
    ON e.docnum = t.docnum
GROUP BY d.docnum,
         e.empnam
;

