日期:2014-05-19  浏览次数:20519 次

字符串问题,高手解决以下~~~~~~~~~~~~~~~~~~~~~~~
1A0001 eeeeeefdsfs NULL
1A0001 NULL bbb
1A0002 NULL 你好12
1A0002 你好11 NULL


计算结果要为
1a0001   eeeeeefdsfs   bbb
1a0002     你好11         你好12

一个sql语句

------解决方案--------------------
select
ID,max(cont1),max(cont2)
from
@t
group by
ID
------解决方案--------------------
select col1,
max(col2) as col2,
max(col3) as col3
from tablename
group by col1

是不是要这个?



------解决方案--------------------
drop table test
create table test(name varchar(20),str1 varchar(20),str2 varchar(20))
insert into test
select '1A0001 ', 'eeeeeefdsfs ',NULL
union all select '1A0001 ',NULL, 'bbb '
union all select '1A0002 ',NULL, '你好12 '
union all select '1A0002 ', '你好11 ',NULL

select name,max(str1) as str1,max(str2) as str2
from test
group by name