Sapiens interview question

Joining tables