Sql天花板功能 [英] Sql ceiling functionality

查看:91
本文介绍了Sql天花板功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有一列是该列的十进制数据类型我需要

Dear Friends,

I have one column which is decimal datatype on that column i need

CEILING.PRECISE(Col1,10000)

在Excel中找到的类型工作输出将如Col3所示,但我需要值为Col2 供您参考12758小于15000这就是为什么Col2值为10000而不是20000,如图所示Excel输出



Col1 Col2 Col3

1429 10000 10000

2857 10000 10000

4253 10000 10000

5670 10000 10000

7088 10000 10000

8505 10000 10000

9923 10000 10000

12758 10000 20000

14175 10000 20000

28351 30000 30000

35438 40000 40000



请帮我这个,因为目前我使用的是不值得的案例陈述。



提前致谢



我尝试过:



帮助关于这一点,我目前正在使用案例tatement是不值得的,甚至考虑计算表来管理案例但根本不值得。

type working which you find in Excel the output will be as shown in Col3 but i need the value as Col2 for your reference 12758 is less then 15000 thats why Col2 value is 10000 not 20000 as shown in Excel output.

Col1 Col2 Col3
1429 10000 10000
2857 10000 10000
4253 10000 10000
5670 10000 10000
7088 10000 10000
8505 10000 10000
9923 10000 10000
12758 10000 20000
14175 10000 20000
28351 30000 30000
35438 40000 40000

Help me regarding this as currently i am using case statement which is not worth.

Thanks in Advance

What I have tried:

Help me regarding this as currently i am using case statement which is not worth, even thinking of tally table to manage case but not worth at all.

推荐答案

没有Excell CEILING.PRECISE函数的SQL equivelant - SQL版本只接受一个参数,不会将整数舍入到10000或任意值。

但是,你可以假装:

There is no SQL equivelant of the Excell CEILING.PRECISE function - the SQL version only accepts a single parameter and will not "round up" integers to 10000 or any arbitrary value.
However, you can "fake it":
SELECT CEILING((Col1 + 10000) / 10000)* 10000 FROM MyTable

应该做什么it。


谢谢朋友
OriginalGriff





我解决了这个问题下面的脚本给我输出



,

I solve the issue the below script is giving me my output

SELECT COALESCE(CASE ROUND(Col1 / 10000,0) WHEN 0 THEN Null ELSE ROUND(Col1 / 10000,0) END * 10000,10000) 





感谢您的代码给我指导输出。



谢谢和问候



Thanks for your code which give me direction for the output.

Thanks and Regards


这篇关于Sql天花板功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆