Meta Interview Question

Solve this problem using Having and Group by