HSBC Interview Question

Q. A question on SQL (about groupby)