mysql分组查询 取最新一条数据

 select * from (
        select
        hai.PROC_INST_ID_ AS processInstanceId,
        case when hai.ACT_NAME_ is null then
        hai.ACT_TYPE_ else hai.ACT_NAME_
        end AS currentActName
        from act_hi_actinst hai
        where hai.PROC_INST_ID_ in
        <foreach collection="IdSet" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
        and hai.TENANT_ID_ =  #{tenantId}
        and hai.`ACT_TYPE_`!= 'sequenceFlow'
        having 1
        order by hai.START_TIME_ desc,   hai.END_TIME_ is null desc, hai.END_TIME_ desc, hai.`TRANSACTION_ORDER_` desc) t
        GROUP BY processInstanceId

你可能感兴趣的:(#,mysql,mysql)