I am trying to use JPA and JPQL to query my entity and return the sum of a column (total days) from the table. I thought I had set it up right but I am getting this error:<
It's not a valid JPQL.
You either should have:
@Query("SELECT SUM(m.totalDays) FROM MyEntity m")
or, make it a native one:
@Query(value = "SELECT SUM(total_days) FROM MyEntity", nativeQuery = true)
change your JPQL to @Query("SELECT SUM(m.totalDays) FROM MyEntity m")