问题描述
我一直在寻找这个问题的答案,但找不到我真正想要的!所以我不得不在这里问..
I've searched for an answer to this all over but couldn't find what i'm really looking for! so i had to ask here..
我不知道如何解释,但这里有一个表格:
i don't know how to explain this but here is a table :
Date BL Client Design Ref1 Ref2 Ref3 Qte
14/01/2013 13011401 A VT VT1 JAUNE XL 3
14/01/2013 13011402 B VT VT2 GRIS L 30
16/01/2013 13011601 D VT VT1 GRIS L 10
16/01/2013 13011602 C VT VT2 GRIS L 32
19/01/2013 13011903 F VT VT2 JAUNE L 15
我正在寻找可能如下所示的结果:
i'm looking for a result that could look like the following:
Date BL Client Design Ref1 Ref2 Ref3 Qte
14/01/2013 13011401 A VT VT1 JAUNE XL 3
14/01/2013 13011402 B VT VT2 GRIS L 62
16/01/2013 13011601 D VT VT1 GRIS L 10
19/01/2013 13011903 F VT VT2 JAUNE L 15
edit: sum Qte 如果有重复 (Design,Ref1, Ref2, Ref3)
edit: sum Qte if there is a duplicate (Design,Ref1, Ref2, Ref3)
不知道这是否可行,但我会感谢您的帮助!
don't know if this is possible but i would appreciate your help!
推荐答案
table : mytable
col1 col2 Col3 col4 col5 col7 col8 col9
14/01/2013 13011401 A VT VT1 JAUNE XL 3
14/01/2013 13011402 B VT VT2 GRIS L 30
16/01/2013 13011601 D VT VT1 GRIS L 10
16/01/2013 13011602 C VT VT2 GRIS L 32
19/01/2013 13011903 F VT VT2 JAUNE L 15
我的理解是你想要在 col4,col5,col7,col8
的基础上进行复制,你可以这样做
What I understood is that You want duplicate on the basis of col4,col5,col7,col8
for this you can do like
SELECT col1,col2,Col3,col4,col5,col7,col8,SUM(col9)
FROM mytable
GROUP BY col4,col5,col7,col8;
在这个组中,其他字段总是返回第一行
In this group by will always return first row for other fields
这篇关于重复时汇总记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!