HSBC interview question

Q. A question on SQL (about groupby)