如何使用Spring Data JPA进行唯一计数?我不想使用@Query
注释。 相当的SQL查询是:
SELECT COUNT(DISTINCT rack) FROM store WHERE id = 10001;
我尝试通过编写以下查询来解决问题,但它无法正常工作:
int countDistinctRackById();
如何使用Spring Data JPA进行唯一计数?我不想使用@Query
注释。 相当的SQL查询是:
SELECT COUNT(DISTINCT rack) FROM store WHERE id = 10001;
我尝试通过编写以下查询来解决问题,但它无法正常工作:
int countDistinctRackById();
这应该可以工作:
Integer countDistinctRackById(Long id);
JpaRepository
,实体类有字段customerId
和decision
,我需要获取决策代码为所需值之一的客户的不同计数。我给方法命名为countDistinctCustomerIdByDecisionIn
,但生成的SQL不是select count(distinct CUSTOMER_ID) ...
而是select distinct count(distinct ID) ...
。 - RomanMitasov