Amazon Interview Question

Group by clause, having clause etc