db group by fix