IBM interview question

One programming and one SQL problem.