The distinct (or unique) specification refers to the entire row being returned. If there are any differences in ssn or last name, you will get all rows which are not exactly the same. It sounds like you only want 1 occurrence of each ssn, but if there are 2 rows with the same ssn_id but different last names, which last name do you want? I find it less confusing to use the group by function in some cases. For this inquiry, I might select a.ssn_id, count (a.ssn), min(last_name), max(last_name) and group by a.ssn_id. I didn’t include b.ssn_id because I’m guessing you are joining a and b when a.ssn_id = b.ssn_id. There’s no point in repeating the ssn_id, but you may be restricting listing of rows from a to those cases where there is a row in b with the same ssn_id. Or you may have left out additional columns you need from b to simplify the question. If so, that could affect the way you write the query.