select * from tb_test order by Convert(float,replace(ac,'%','')) asc
create table temp (A int, B int, C varchar(10)) insert temp select 10, 3, '4.5%' union all select 31, 9, '3.2%' union all select 12, 8, '2.1%' select * from temp order by left(c,len(c)-1) asc
将 nvarchar 值 '82.5%' 转换为数据类型为 int 的列时发生语法错误。 格式该怎么转换呢
可以起作用啊declare @tb_test table(ac varchar(10)) insert into @tb_test select '52.2%' union select '65.4%' union select '54.8%'select * from @tb_test order by ac asc
select * from tb_test order by Convert(numeric(9,2),replace(ac,'%','')) asc
select * from tb_test order by Cast(replace(ac,'%','') as numeric(9,2)) asc
insert temp
select 10, 3, '4.5%' union all
select 31, 9, '3.2%' union all
select 12, 8, '2.1%'
select * from temp order by left(c,len(c)-1) asc
格式该怎么转换呢
insert into @tb_test
select '52.2%'
union select '65.4%'
union select '54.8%'select * from @tb_test order by ac asc