If I understand correctly, it looks like you are trying to join the sub column if it matches. If there is no match on sub , you want it to select the “first” line for this acctnum . Is it correct?
If this is the case, you need to leave the union in complete coincidence, and then perform another left join in the select statement, which defines a division that matches the smallest sub value for this acctnum . The row_number() function can help you with this, for example:
select t1.acctnum, t1.sub, t1.fname, t1.lname, t1.phone, isnull(t2_match.division, t2_first.division) as division from table1 t1 left join table2 t2_match on t2_match.acctnum = t1.acctnum and t2_match.sub = t1.sub left join ( select acctnum, sub, division, row_number() over (partition by acctnum order by sub) as rownum from table2 ) t2_first on t2_first.acctnum = t1.acctnum
EDIT
If you do not care about which record you will return from table 2, if the corresponding sub file does not exist, you can combine two different queries (one of which corresponds to a sub-item, and one - only min or max division) with a union .
select t1.acctnum, t1.sub, t1.fname, t1.lname, t1.phone, t2.division from table1 t1 join table2 t2 on t2.acctnum = t1.acctnum and t2.sub = t1.sub union select t1.acctnum, t1.sub, t1.fname, t1.lname, t1.phone, min(t2.division) from table1 t1 join table2 t2 on t2.acctnum = t1.acctnum left join table2 t2_match on t2_match.acctnum = t1.acctnum and t2_match.sub = t1.sub where t2_match.acctnum is null
Personally, I don't find union syntax more attractive, and now you need to maintain the request in two places. For this reason, I approve of the row_number() approach.