Infosys interview question

self join query