分组求和mysql> SELECT coalesce(name, '总数'), SUM(singin) as singin_count FROM employee_tbl GROUP BY name WITH ROLLUP; +--------------------------+--------------+ | coalesce(name, '总数') | singin_count | +--------------------------+--------------+ | 小丽 | 2
; SELECT temp.*,(@csum := total + @csum) as csums from ( ) as total,month(openedDate) as date from zt_bug where openedDate >= CONCAT(YEAR(NOW()), '-01-01 00:00:01') and `status` <> 'closed' GROUP BY date )as temp 参考:https://blog.csdn.net/qcyfred/