Tech Mahindra Interview Question

Showed SQL query and asked to solve