Quest Analytics interview question

SQL join logic