GlobalLogic interview question

Basic Programming SQL a puzzle question