如何将两行合并为一个。我的问题 [英] how to merge two rows into one.Below my question

查看:102
本文介绍了如何将两行合并为一个。我的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sql server 2008中有以下格式的数据



I have data in the following format in sql server 2008

Phone	          Mobile	  Office		Other_Phone	Other Mobile	
02136349138	03008219955	02132573370			         03452219580		
02136349138	03008219955	02132573370		0214500042





i必须将以下格式分成一行



i have to make it into the following format into one row

Phone	          Mobile	  Office		Other_Phone	Other Mobile	
02136349138	03008219955	02132573370	         0214500042      03452219580





添加了代码块 - OriginalGriff [/ edit]



[edit]Code block added - OriginalGriff[/edit]

推荐答案

我会创建一个新表并从旧表中填充它:



I would create a new table and populate it from the old one:

SELECT Phone, Mobile, Office, MAX(OtherPhone) AS OtherPhone, MAX(OtherMobile) AS otherMobile
INTO MyNewTable
FROM MyTable
GROUP BY Phone, Mobile, Office

然后您可以删除旧表并替换它(当您确定它是正确的时)

You can then delete the old table and replace it (when you are sure it is right)


这篇关于如何将两行合并为一个。我的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆