例如:
原始表格:
-----------------------------------------------------
编号 A1 A2 A3
1 30.8886 25.9878 25.8978
-----------------------------------------------------Select A1, A2, A3 from T
之后的效果是:
-----------------------------------------------------
编号 A1 A2 A3
1 30.89 25.99 25.90
-----------------------------------------------------
要在查询语句里面实现!
请各位帮帮忙!谢谢了!
原始表格:
-----------------------------------------------------
编号 A1 A2 A3
1 30.8886 25.9878 25.8978
-----------------------------------------------------Select A1, A2, A3 from T
之后的效果是:
-----------------------------------------------------
编号 A1 A2 A3
1 30.89 25.99 25.90
-----------------------------------------------------
要在查询语句里面实现!
请各位帮帮忙!谢谢了!
--------------------------------------- --------------------------------------- ------------------------------
30.8900 25.9900 25.9000(1 row(s) affected)
*/
select cast(A1 as numeric(28,2) as A1,
cast(A2 as numeric(28,2) as A2,
cast(A3 as numeric(28,2) as A3
from T
cast(A2 as numeric(28,2)) as A2,
cast(A3 as numeric(28,2)) as A3
from T
---------------------------------------
30.89(1 row(s) affected)
*/
insert into @a select 1,30.8886,25.9878,25.8978select * from @a
select 编号,cast(round(a1,2)as numeric(18,2)),cast(round(a2,2)as numeric(18,2)),cast(round(a3,2)as numeric(18,2)) from @a
insert into @a select 1,30.8886,25.9878,25.8978
select 编号,cast(round(a1,2)as numeric(18,2)) a1,cast(round(a2,2)as numeric(18,2)) a2,cast(round(a3,2)as numeric(18,2)) a3 from @a
-------------------
编号 a1 a2 a3
1 30.89 25.99 25.90
select round(A1, 2), .... from T
这就可以了
create table t2 (
编号 int,
A1 numeric(12,4),
A2 numeric(12,4),
A3 numeric(12,4)
)insert into t2
values(1,30.8886,25.9878,25.8978)select * from t2/*
(所影响的行数为 1 行)编号 A1 A2 A3
----------- -------------- -------------- --------------
1 30.8886 25.9878 25.8978(所影响的行数为 1 行)
*/select 编号,cast(a1 as numeric(12,2)),cast(a2 as numeric(12,2)),cast(a3 as numeric(12,2)) from t2/*
编号
----------- -------------- -------------- --------------
1 30.89 25.99 25.90(所影响的行数为 1 行)
*/
insert into trr select 1,30.8886,25.9878,25.8978select 编号,cast(round(A1,2) as numeric(8,2)),cast(round(A2,2) as numeric(8,2)),cast(round(A3,2) as numeric(8,2)) from trr
应用12,13楼的方法