Workaround for queries with nested .group