Prepare queries example for result groups, filtering and sorting