Add group_by() and count() in the SQL