X interview question

Including SQL and programming problem.