Multiple COUNT aggregate in same QueryBuilder

Is it possible to include 2 or more COUNT aggregate in the same query/request? I’ve tried it and got no execution error but the result for the second COUNT is not correct. Perhaps I’m doing something else wrong. I’m elaborating my scenario below.

Social Post has 1:N Comment (as comments)
Social Post has 1:1 Picture (as picture)
Picture has 1:N Users (as likes)

  1. I want to know the total amount of likes and comment on each Social Post retrieved.
  2. The totalLikes property is populated by the first aggregate.
  3. The another property stands for the total amount of comments.
  4. The totalComments property is populated by manually counting on the Comment table (would be replaced with the another property if the aggregate worked).
  5. When I add the second aggregate, the first one also messes up (totalLikes and another both have the same unknown number).

QueryBuilder:

Counter for totalComments (manually on Comments table)

Result with 1 aggregate (totalLikes only | Both counters are correct)

Result with 2 aggregated (totalLikes and another are incorrect, must be as in image above)

Thanks in advanced

Hi @RAFAEL_PEREZ

We will investigate this issue and respond as soon as possible.

Regards,
Inna

We were able to reproduce your problem.
The internal ticket BKNDLSS-21349 is created, we will notify you when it will be fixed

Regards,
Inna

1 Like

Hi,

Thanks, I’ll keep in the loop.

I am wondering have this been resolved? I have similar issue with multiple count() in an api call. Thank you!

Hi @Jimmy_Jimmy,

yes, the issue is fixed, but not released yet. I think tomorrow it will be released.
In any way, we’ll keep you informed here about any progress and news regarding this issue.

Regards,
Stanislaw

Good to know, thank you! :slight_smile: