Mysql求和和和分组方法



输入

日期 nbsp nbsp nbsp nbsp 积分 nbsp nbsp nbsp nbsp nbsp电子邮件

2012-07-01 nbsp nbsp;5 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;@sample.com
2012-07-01 nbsp nbsp;6 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;b@sample.com
2012-07-01 nbsp nbsp;2 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;c@sample.com

2012-07-02 nbsp nbsp;5 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;d@sample.com

2012-07-03 nbsp nbsp;8 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;e@sample.com
2012-07-03 nbsp nbsp;7. nbsp nbsp nbsp nbsp nbsp nbsp nbsp f@sample.com
2012-07-03 nbsp nbsp;1. nbsp nbsp nbsp nbsp nbsp nbsp nbsp y@sample.com

2012-07-04 nbsp nbsp;3 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;x@sample.com
22012-07-04 nbsp nbsp;2 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;f@sample.com

2012-07-05 nbsp nbsp;3 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;g@sample.com
2012-07-05 nbsp nbsp;9 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;b@sample.com

输出

日期 nbsp nbsp nbsp nbsp 积分

2012-07-01 nbsp nbsp;13
2012-07-02 nbsp nbsp 5
2012-07-03 nbsp nbsp;16
2012-07-04 nbsp nbsp 5
2012-07-05 nbsp nbsp;12

建议我使用MySQL查询输出,如上面的

尝试

 SELECT `date`, SUM(`Points`) AS sumPoint FROM table GROUP BY `date`

注意:不要忘记用`包装date列,因为DATE是mySQL 的保留关键字

SELECT date,SUM(Points)AS sumPointFROM表按日期分组

由于日期列可能是表中的日期时间或日期类型

最新更新