Diagnose MySQL joins and GROUP BY/HAVING errors | Amazon SQL Question