GlobalLogic interview question

Basic sql query