UBS Interview Question

Question on aggregate function on sql