Heim  >  Artikel  >  Backend-Entwicklung  >  mysql一个group by的有关问题,求解一上

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

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

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)
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn