Pergunta de entrevista da empresa Tech Mahindra

Showed SQL query and asked to solve