Mysql总和和按分组方法 [英] Mysql Sum and Group By Method
问题描述
日期    要点
电子邮件
2012-07-01 5 a@sample.com
2012-07-01 6                b@sample.com
2012-07-01 2 c@sample.com
<2012-07-02 5&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; d@sample.com
2012-07-03 8&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; e@sample.com
2012-07-03 7
f@sample.com
2012-07-03 1
y@sample.com
2012-07-04 3&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; x@sample.com
2012-07-04 2&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; f@sample.com
2012-07-05 3&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; g@sample.com
2012-07-05 9&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; b@sample.com
输出
日期 要点
<2012> 2012-07-01 13
2012-07-02 5
2012-07-03 16元
2012-07-04 5
2012-07-05 12
建议我使用MySQL Query作为输出,如上所示
注意:不要忘记包装 date
列中`
作为 DATE 是mySQL的保留关键字
Input
Date Points Email
2012-07-01 5 a@sample.com
2012-07-01 6 b@sample.com
2012-07-01 2 c@sample.com
2012-07-02 5 d@sample.com
2012-07-03 8 e@sample.com
2012-07-03 7
f@sample.com
2012-07-03 1
y@sample.com
2012-07-04 3 x@sample.com
2012-07-04 2 f@sample.com
2012-07-05 3 g@sample.com
2012-07-05 9 b@sample.com
Output
Date Points
2012-07-01 13
2012-07-02 5
2012-07-03 16
2012-07-04 5
2012-07-05 12
Suggest me an MySQL Query for output like the above
try
SELECT `date`, SUM(`Points`) AS sumPoint FROM table GROUP BY `date`
Note : dont forget to wrap date
column with `
as DATE is reserve keyword of mySQL
这篇关于Mysql总和和按分组方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!