added group by to query 1