Forgot to add aggregate functions on grouped data from SQL queries