Modak Interview Question

SQL question based on self join concept