Pregunta de entrevista de Virtusa

During technical interview a coding problem and questions to be solved using database was given.