Pergunta de entrevista da empresa CoStar Group

How do get values from two tables joined by a ref I’d, getting a value from second table if it’s there and bill if it’s not?