COUNT aggregate function with subquery doesn't work

Hello everyone, could someone enlighten me if it is possible to use any aggregation functions within SQL syntax with subquery. Without COUNT function everything works as expected. (Also there is some non-standart behaviour: when instead of COUNT(client) I use just * symbol it returns all documents properties, showed in the second screenshoot).
Here an example:

Error thrown by aforementioned query:

  "error": {
    "reason": "There was internal problem at backend",
    "details": "class cannot be cast to class ( and are in unnamed module of loader @1174aa3)",
    "type": "ClassCastException"
  "status": 503