Q: How does return SUM() in spring data jpa I am uning Spring boot with spring data jpa.
I've made repository that extends JpaRepository and I want to get SUM() of table results.
table schema is like
point
user_index, user_point
and query to get point total is
select SUM(user_point)
from point
where user_index = 1;
what is the best way to get this result?
I am considering to use native query, but I think to use JPA Repository is better.

A: Have you tried the query you wrote? I believe jpa query does support sum operator
@Query(SELECT SUM(p.user_point) FROM point p WHERE p.user_index = :user_index)
float totalPointByUser(@Param("user_index") Long user_index) 

