implemented group by
added group by clause