Implemented query result grouping capability