package be.seeseepuff.allowanceplanner.repository;

import be.seeseepuff.allowanceplanner.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends JpaRepository<User, Integer> {
    @Query("SELECT COALESCE(SUM(h.amount), 0) FROM History h WHERE h.userId = :userId")
    long sumHistoryAmount(int userId);
}
