Pregunta de entrevista de Infosys

They have asked to write Query for a given scenario.