change to case, added group by