Home  >  Article  >  Backend Development  >  mysql一个group by的有关问题,求解一上

mysql一个group by的有关问题,求解一上

WBOY
WBOYOriginal
2016-06-13 12:56:05789browse

mysql一个group by的问题,求解一下
现在有一个小问题,但是不太知道如何实现,group by有限制语句么??
比如表示这样的

a  b  c  d

1  2  3  1
1  3  5  2 
1  5  5  4
2  1  2  1
2  1  2  2

现在是想 提取出  a b c 然后sum (d);
select a,b,c,sum(d) from table group by a 加点什么限制条件呢?

取出的结果是
1  2  3  1
1  3  5  2
1  5  5  4
2  1  2  3

就是当a b c都相同的时候  把d相加  列为一列


------解决方案--------------------
select a,b,c,sum(d) from table group by concat(a,b,c)
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn