1

I am doing a lot of arithmetic and joins in my actual Query, all of which are working fine.

I have the following (Simplified version for the purpose of this question) working custom query, where i am counting the number of instances with 'isSuccess == true':

@Query("SELECT NEW com.xyz.MyEntity(S.name, SUM(S.isSuccess)) FROM Sample AS S")
public List<MyEntity> caclulateResults();

However I would like to count the 'S.isSuccess = false' instead and I am curious about what would be the easiest way to achieve this? The JPA documentation is of not much help here. Thank you!

ZOXIS
  • 578
  • 5
  • 15

1 Answers1

1

I resolved this by doing.

SUM(CASE S.isSuccess WHEN true THEN 0 ELSE 1 END)
ZOXIS
  • 578
  • 5
  • 15