34,594
社区成员
发帖
与我相关
我的任务
分享
create table a5(x decimal(5,1))
insert into a5(x)
select 0 union all
select 0.2 union all
select 0.6 union all
select 1.1 union all
select 1.7 union all
select 2.3 union all
select 2.9
select x,
x-x%0.5 'y'
from a5
/*
x y
--------------------------------------- ---------------------------------------
0.0 0.0
0.2 0.0
0.6 0.5
1.1 1.0
1.7 1.5
2.3 2.0
2.9 2.5
(7 row(s) affected)
*/
select floor(0.5*2)/2--0.5
select floor(0.4*2)/2--0