日期:2014-05-18 浏览次数:20804 次
declare @t table(id int, sub varchar(10), pp varchar(10))
insert @t select 1 , 'd ', 'c:\s '
union all select 1 , 's_id ' , '54 '
union all select 2 , 'd ' , 'd:\f '
union all select 2 , 's_id ' , '66 '
select
id,
(select max(pp) from @t where id=t.id and isnumeric(pp)=1),
(select max(pp) from @t where id=t.id and isnumeric(pp)=0)
from
@t t
group by ID
--------
(所影响的行数为 4 行)
id
----------- ---------- ----------
1 54 c:\s
2 66 d:\f
(所影响的行数为 2 行)