Kumaran Systems Interview Question

Query on mongodb with groupby match and sum