SQL - 按ID字段合并记录

时间:2016-10-13 13:09:10

标签: sql sql-server

我有一个select语句,我得到了

WebView

我希望得到像这样的合并行

ProductID  Gender Color Type     AgeRange
344842     Boys   NULL  NULL     NULL       
344842     NULL   Black NULL     NULL
344842     NULL   NULL  Leggings NULL   
344842     NULL   NULL  NULL     2 to 4 Years

3 个答案:

答案 0 :(得分:1)

select 
productid, max(Gender) as Gender, 
max(Color) as Color, max(Type) as Type, max(AgeRange) as AgeRange
from
table
group by 
productid

答案 1 :(得分:1)

您可以尝试这样

java -Xmx800m -Dstorage.diskCache.bufferSize=7200 ...

答案 2 :(得分:1)

select id,max(gender) gender, max(color) color, max(Type) Type, max(AgeRange) AgeRange from yourtable group by id