• I don't see what's wrong with your query other than you don't have a loannumber column. It is loan_number.

    Post the ddl and sample data for TableC and give expected output and someone should be able to help.