fixed a group by clause