百分比1  百分比2 百分比3 百分比4 百分比5
5%  25%   5%       50%     75%   请问如何用简便方法找出以上记录的最大百分比数 以上记录值均为字符型

解决方案 »

  1.   

    declare @t table(百分比1 varchar(10),百分比2 varchar(10),百分比3 varchar(10),百分比4 varchar(10),百分比5 varchar(10))
    insert into @t select '5%','25%','5%','50%','75%'select max(cast(replace(col,'%','') as dec(10,2))) 
    from
    (select 百分比1 as col from @t 
    union all
    select 百分比2 from @t 
    union all
    select 百分比3 from @t 
    union all
    select 百分比4 from @t 
    union all
    select 百分比5 from @t)a