SELECT
dept_id,
version,
manage_three,
manage_four,
manage_five,
manage_six,
manage_seven,
manage_eight,
manage_nine,
manage_ten
FROM
(select * from ahrs_post_plan order by version desc) A
WHERE
dept_id = 29
OR dept_id IN ( SELECT dept_id FROM sys_dept WHERE FIND_IN_SET( '29', ancestors ) )
AND STATUS = '0'
这是未分组的,有不同版本的数据
这是分组后的
问题是我使用了sum(),它把所有记录都加了,我只想计算分组后的和
描述的不是很清楚,也没说按什么分组,只能通过截图和标题猜测大概这样,另该语法不一定支持(sql_mode)