实际问题场景:
查询得到同一个线索下,级别最高(10级别)的一条记录,最后得到对象组成的list,list里存的都是每条线索里级别最高的。
caseId:案件 级别:官员级别 clueId : 线索 得到结果:
select CASE_INFO."CASE_ID",CASE_INFO."CLUE_ID",CASE_INFO."CITY_CODE",CASE_INFO."COUNTY_CODE",CASE_INFO."CASE_USER_NAME",CASE_INFO."CASE_USER_LEVEL",CASE_INFO."CASE_USER_DWZW",CASE_INFO."CASE_BAFS",CASE_INFO."CASE_CBDW",CASE_INFO."CASE_CBR",CASE_INFO."CASE_ZLCS",CASE_INFO."CASE_CZQK",CASE_INFO."CASE_BLJG",CASE_INFO."CASE_BJSJ",CASE_INFO."CASE_JYAQ",CASE_INFO."CASE_DJCF",CASE_INFO."CASE_ZWCF",CASE_INFO."CASE_ZZCL",CASE_INFO."CASE_ZZCLFS",CASE_INFO."CASE_CFSJ",CASE_INFO."CASE_CFJDWH",CASE_INFO."CASE_CFJD",CASE_INFO."CASE_AJLB",CASE_INFO."CASE_SFYSSF",CASE_INFO."CASE_SFFKYSDW",CASE_INFO."CASE_SFTBBG",CASE_INFO."USER_ID",CASE_INFO."USER_NAME",CASE_INFO."FIRST_ADD_TIME",CASE_INFO."LAST_EDIT_TIME",CASE_INFO."CASE_DWLB" from CASE_INFO
inner join(select min(CASE_USER_LEVEL) as CASE_USER_LEVEL,CLUE_ID from CASE_INFO group by CLUE_ID) c on
CASE_INFO.CASE_USER_LEVEL=c.CASE_USER_LEVEL and CASE_INFO.CLUE_ID=c.CLUE_ID
注:1.除去黑体字段其他查询字段为业务所需字段
2.最后需要关联两个字段才能达到效果