Query to group by multiple fields

May be a concrete example will help. Can you show what is your requirement with example?