第一种方法:
SELECT
SUBSTRING_INDEX(GROUP_CONCAT(to_user_code ORDER BY eppntur.modify_time desc),',',1)
-- GROUP_CONCAT(user_code ORDER BY eppntur.modify_time desc)
FROM
es_project_process_node_to_user_ref eppntur
WHERE
eppntur.disabled = 'FALSE'
AND eppntur.ppnu_code in ('PPNU202105241547132385730','PPNU202106111538184828409')
GROUP BY
eppntur.ppnu_code ORDER BY eppntur.modify_time desc
第二种方法:
SELECT temp.bpnu_code AS bpnuCode, temp.book_type AS bookType, temp.page_num AS pageNum, temp.node_code AS nodeCode, ( SELECT node_name FROM es_node WHERE node_code = temp.node_code ) AS nodeName, ( SELECT GROUP_CONCAT(eu.user_name) FROM es_book_process_node_to_user_ref bpntur LEFT JOIN es_user eu ON ( eu.user_code = bpntur.to_user_code ) WHERE bpntur.disabled = 'FALSE' AND bpntur.bpnu_code = temp.bpnu_code AND bpntur. STATUS != 'UBABLED' ) AS assignUserName, ( SELECT GROUP_CONCAT(bpntur.to_user_code) FROM es_book_process_node_to_user_ref bpntur WHERE bpntur.disabled = 'FALSE' AND bpntur.bpnu_code = temp.bpnu_code AND bpntur. STATUS != 'UBABLED' ) AS assignUserCode, CASE WHEN temp. STATUS = 'WAITING_ACTIVATE' THEN 'UNALLOCATED' WHEN temp. STATUS = 'WAITING_CLAIM' THEN 'UNCLAIMED' WHEN temp. STATUS = 'TO_FINISH' THEN 'CLAIMED' ELSE '' END AS state FROM ( SELECT * FROM es_book_process_node_from_user_ref WHERE disabled = 'FALSE' AND book_code = #{bookCode} AND book_type != 'ALL' AND page_num != 'ALL' ORDER BY modify_time DESC LIMIT 1000 ) AS temp GROUP BY temp.book_type, temp.page_num ORDER BY temp.book_type