首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

字符串有关问题,高手解决以下~

2012-01-29 
字符串问题,高手解决以下~~~~~~~~~~~~~~~~~~~~~~~1A0001eeeeeefdsfsNULL1A0001NULLbbb1A0002NULL你好121A0

字符串问题,高手解决以下~~~~~~~~~~~~~~~~~~~~~~~
1A0001eeeeeefdsfsNULL
1A0001NULLbbb
1A0002NULL你好12
1A0002你好11NULL


计算结果要为
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

热点排行
Bad Request.