SELECT * FROM (select *from pf_module_work t left join pf_module_work_history h on h.work_id = t.work_id WHERE h.id IN ( select max(id) from pf_module_work_history h GROUP BY h.creator //子表根据userId分组,然后查出所有用户的最大的id记录,也就是最新的一条数据的id ) ) a, (SELECT h.creator ,count(h.creator) as commitTimes FROM pf_module_work_history h GROUP BY h.creator) AS b where a.creator = b.creator
1.
标签:每组,creator,work,module,分组,MySQL,pf,id From: https://www.cnblogs.com/onlyzhangmeng/p/17046726.html