Users may use any number of labels so my query cannot know what labels are possible
This isn't going to work the way you are thinking.
Filters find issues. They have nothing to say about how they are then presented to the user (slight exception - the "order by" clause is used in a handful of places).
There is no group-by in the filters, because that's formatting, not results.
You will need to think about where you are reporting the results of running a filter and how that might "group by".
You can sort by lables in the Issue Navigator page. But consider what happens when there are multiple labels on some issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.