当前位置:网站首页>Oracle中计算除法——解决除数为零报错
Oracle中计算除法——解决除数为零报错
2022-06-26 07:01:00 【牛奶咖啡13】
一、问题描述
在Oracle数据库中,需要使用到除法,但是除数有可能为零,如果直接使用sql中的除法运算符(/),则会报错。

二、问题分析
通过分析发现,是除数为0时会出现问题,那么我们可以先排除除数为零时直接指定结果为0,然后在进行除法计算(另外由于除法会导致结果的小数位数会很长,需要配合Round函数截取对应保留的小数位数)。
三、解决办法
3.1、计算除法的语法和示例
--Oracle中计算除法语法
SELECT case WHEN(NVL(除数, 0))!=0 THEN round(被除数 / 除数,需要保留的小数位数) ELSE 0 END result FROM DUAL
3.2、计算除法使用到的函数内容
Oracle中Case When的用法
https://coffeemilk.blog.csdn.net/article/details/121215294
Oracle中实现过滤非空内容但保留空内容数据(或不等于条件包含空值)
https://coffeemilk.blog.csdn.net/article/details/124834869
边栏推荐
- Solve the problem of transparency at the bottom of dialog
- 二叉树中和为某一值的路径(一)(二)(三)(剑指offer)
- 【图像融合】基于耦合特征学习的多模式医学图像融合附matlab代码
- shell 输入验证仅限字母数字
- 报错问题Parameter index out of range(0 < 1) (1 > number of parameters,which is 0
- Six stones Management: exaggerating the achievements, whether the parties themselves know
- 在公司逮到一个阿里10年的测试开发,聊过之后大彻大悟...
- NumPy学习挑战第五关-创建数组
- 数据湖架构之Hudi编译篇
- Interviewer: what is the difference between a test plan and a test plan?
猜你喜欢
![[004] [stm32] MDK project configuration and commissioning](/img/a8/9817cdbbce557a92739de494490706.jpg)
[004] [stm32] MDK project configuration and commissioning

unity之EasyAR使用

Stm32f1 and stm32subeide programming example - thermal sensor driver

MySQL基础用法01

NumPy学习挑战第四关-NumPy数组属性

SecureCRT运行SparkShell 删除键出现乱码的解法

If you meet a female driver who drives didi as an amateur, you can earn 500 yuan a day!

Bugku练习题---MISC---富强民主

When asked during the interview, can redis master-slave copy not answer? These 13 pictures let you understand thoroughly

海量日志采集工具——Flume
随机推荐
[digital signal processing] basic sequence (basic sequence lists | unit pulse sequence | unit pulse function | discrete unit pulse function | difference between unit pulse function and discrete unit p
On a classical problem
Market development status analysis and investment risk outlook report of China's battery industry 2022-2027
[image detection] image saliency detection based on ITTI model with matlab code
Bugku exercise ---misc--- prosperity, strength and democracy
面试官:测试计划和测试方案有什么区别?
Market survey of China's coal to liquid industry and analysis report on investment competitiveness during the "14th five year plan" 2022-2027
MySQL基础用法01
Differences, advantages and disadvantages between synchronous communication and asynchronous communication
Live broadcast Preview - fire safety instructor training "cloud class" is about to start!
China polyimide film market demand and future investment risk outlook report 2022-2027
Analyze 5 indicators of NFT project
LabVIEW Arduino tcp/ip remote smart home system (project part-5)
LabVIEW arduino TCP / IP Remote Intelligent Home System (Project section - 5)
【路径规划】基于改进人工势场实现机器人路径规划附matlab代码
[feature extraction] feature selection of target recognition information based on sparse PCA with Matlab source code
Load balancer does not have available server for client: userservice problem solving
China peek market outlook and future strategic planning proposal report 2022-2027
Bugku练习题---MISC---富强民主
[image segmentation] blood vessel extraction from retinal fundus images based on maximum principal curvature with matlab code
