Tredence interview question

Sql query using joins and branching