Amazon interview question

Group by clause, having clause etc