JPA使用 GROUP_CONCAT()

我们使用jpa 将同一分类下的所有结果都统计在一行 一定会group_concat()函数

public interface ViewLbResultCount1Repo extends JpaRepository {
    @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 findViewLbReportUpdateRate();

}

结果大概是这样的
在这里插入图片描述
group_concat( temp.test_result SEPARATOR ‘,’ )
这个是将结果汇总到一起 用‘,’隔开

你可能感兴趣的:(java,开发中遇到的问题,mysql)