如何将两行的值合并到具有相同ID的单行中? [英] How to merge values of two rows into single row for same id?
本文介绍了如何将两行的值合并到具有相同ID的单行中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个表(列表)中有数据,如下所示,
I have data in a table(list) as shown below,
id no1 no2
1000 0 511
1000 820 0
我需要如下所示的数据,
I need data like shown below,
id no1 no2
1000 820 511
任何人都可以解决这个问题.预先感谢.
Can anyone solve this. Thanks in advance.
推荐答案
您可以使用sum或max:
You can use sum or max:
select id,max(no1),max(no2) from tab_name group by id;
或
select id,sum(no1),sum(no2) from tab_name group by id;
这篇关于如何将两行的值合并到具有相同ID的单行中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文