我们使用jpa 将同一分类下的所有结果都统计在一行 一定会group_concat()函数
public interface ViewLbResultCount1Repo extends JpaRepository<ViewLbResultCount1,Integer> {
@Query(value = "SELECT sample_id AS sample_id,result AS result,create_time AS create_time," +
"update_time AS update_time,test_subject_id AS test_subject_id,set_meal_id AS set_meal_id" +
",project_name AS project_name,project_num AS project_num,normal_num AS normal_num,abnormal_num AS abnormal_num," +
" GROUP_CONCAT(result_num SEPARATOR ',') AS result_num "+
" from " +
" view_lb_result_count1" +
" group by test_subject_id"
,
nativeQuery = true
)
List<ViewLbResultCount1> findViewLbReportUpdateRate();
}
结果大概是这样的
group_concat( temp
.test_result
SEPARATOR ‘,’ )
这个是将结果汇总到一起 用‘,’隔开