Pregunta de entrevista de X

Including SQL and programming problem.