日期:2014-05-17  浏览次数:20377 次

.netdatatable 合并相同行
源数据:
  姓名       电话    地址
1.小李       null   xxx
2.小李       13800  null


最终数据:
  姓名       电话     地址
1.小李       13800  xxx


求代码


   
------解决方案--------------------
select B.name,max(B.phone),max(B.address) from 
( select A.name,
         case when A.phone is null then "" end,
         case when A.address is null then "" end
  from table A) B

please check it out


------解决方案--------------------
group by B.name
------解决方案--------------------
引用:
Quote: 引用:

select B.name,max(B.phone),max(B.address) from 
( select A.name,
         case when A.phone is null then "" end,
         case when A.address is null then "" end
  from table A) B

please check it out

不是sql  是datatable


不是一条路,也可到罗马。sql能解决,不也很好嘛
------解决方案--------------------
试一下DataTable.Merge方法
------解决方案--------------------
实在不行就用个笨办法,把表数据循环一下重新添加到一个表里,有重复的就只添加一次。