Hi,
I do not think ProcessInstanceQuery supports grouping directly, but you can use the native queries to write your own SQL statements.
For example:
<code>List<HistoricProcessInstance> processes = historyService.createNativeHistoricProcessInstanceQuery().sql("select * from ACT_HI_PROCINST…").list();</code>
Also, for performance reasons, it is better to use the HistoryService, than the RuntimeService.
br,
Vlad