取整问题

ColdFusion_JK 2008-02-26 05:18:24
比如
select 3/2
我怎么能得到
2?
就是只要除 有余数 就进1...
...全文
155 22 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
lhsxsh 2008-03-04
  • 打赏
  • 举报
回复
select Cast((11) AS numeric)/2
lhsxsh 2008-03-04
  • 打赏
  • 举报
回复
select ceiling(3*1.0/2)
leisure_cool 2008-03-04
  • 打赏
  • 举报
回复

declare @a int,@b int
set @a=3
set @b=2
select ceiling(cast(@a as float)/@b)
zefuzhang2008 2008-02-27
  • 打赏
  • 举报
回复
select ceiling(3*1.0/2)
dawugui 2008-02-26
  • 打赏
  • 举报
回复
select result = ceiling(3*1.0/2)

/*
result
-----------
2
(所影响的行数为 1 行)
*/
cxmcxm 2008-02-26
  • 打赏
  • 举报
回复
SELECT CEILING(3*1.0/2)
zdlou 2008-02-26
  • 打赏
  • 举报
回复
select ceiling(3*1.0/2)
zefuzhang2008 2008-02-26
  • 打赏
  • 举报
回复
呵呵,我同意以上答案
fcuandy 2008-02-26
  • 打赏
  • 举报
回复
hehe
dobear_0922 2008-02-26
  • 打赏
  • 举报
回复
还是11楼的最简洁,呵呵,,,
select (3+2-1)/2
fcuandy 2008-02-26
  • 打赏
  • 举报
回复
SELECT  CASE WHEN 3%2!=0 THEN 1+3/2 ELSE 3/2 END

SELECT ISNULL(LEFT(NULLIF(3%2,0),0)+RTRIM(3/2+1),3/2)

SELECT CEILING(3*1.0/2)
dobear_0922 2008-02-26
  • 打赏
  • 举报
回复
declare @num1 int,@num2 int
set @num1=3
set @num2=2

select (@num1+@num2-1)/@num2

/*
-----------
2

(1 row(s) affected)
*/
dobear_0922 2008-02-26
  • 打赏
  • 举报
回复
declare @num1 int,@num2 int
set @num1=3
set @num2=2

select (@num1+@num2-1)/@num2

/*
-----------
2

(1 row(s) affected)
*/
wzy_love_sly 2008-02-26
  • 打赏
  • 举报
回复

select ceiling(3*1.0/2)

2
--例子

SELECT CEILING($123.45), CEILING($-123.45), CEILING($0.0)


124.00 -123.00 0.00
utpcb 2008-02-26
  • 打赏
  • 举报
回复
select floor(convert(float,被除数)/除数+0.99999) 你如果要精度的话就在后面灾添9
-狙击手- 2008-02-26
  • 打赏
  • 举报
回复
select ceiling(3*1.0/2)
nj_1st_excellence 2008-02-26
  • 打赏
  • 举报
回复
select ceiling(3/2.0)
OracleRoob 2008-02-26
  • 打赏
  • 举报
回复
--需要对整数先转换,如:乘以1.0,或直接cast(3 as decimal(10,2))

select ceiling(3*1.0/2)
qiyousyc 2008-02-26
  • 打赏
  • 举报
回复
select ceiling(@num1*1.0/@num2)
areswang 2008-02-26
  • 打赏
  • 举报
回复
SELECT CEILING(3.0/2)
加载更多回复(2)

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧