Workaround to get counts working for grouped queries.