保留两位小数---测试数据--- if object_id('[tb]') is not null drop table [tb] go create table [tb]([col] numeric(6,5)) insert [tb] select 0.1234 union all select 0.15673 union all select 0.12333 union all select 0.14566
---查询--- select ltrim(cast(col as dec(18,2)))+'%' as col from [tb]---结果--- col ----------------------------------------- 0.12% 0.16% 0.12% 0.15%(所影响的行数为 4 行)
汗..再乘100select ltrim(cast(col*100 as dec(18,2)))+'%' as col from [tb] /** col ----------------------------------------- 12.34% 15.67% 12.33% 14.57%(所影响的行数为 4 行) **/
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([col] numeric(6,5))
insert [tb]
select 0.1234 union all
select 0.15673 union all
select 0.12333 union all
select 0.14566
---查询---
select ltrim(cast(col as dec(18,2)))+'%' as col from [tb]---结果---
col
-----------------------------------------
0.12%
0.16%
0.12%
0.15%(所影响的行数为 4 行)
/**
col
-----------------------------------------
12.34%
15.67%
12.33%
14.57%(所影响的行数为 4 行)
**/