Oracle Function: NVL
Description
The Oracle/PLSQL NVL function lets you substitute a value when a null value is encountered.
NVL函数是当出现空值时替换一个值
Syntax
NVL( string1, replace_with )
|
String1 |
The string to test for a null value. |
|
replace_with |
The value returned if string1 is null. |
Example
For example:
|
SELECT NVL(supplier_city, 'n/a') |
The SQL statement above would return 'n/a' if the supplier_city field contained a null value. Otherwise, it would return the supplier_city value. |
|
SELECT supplier_id, |
This SQL statement would return the supplier_name field if the supplier_desc contained a null value. Otherwise, it would return the supplier_desc. |
|
SELECT NVL(commission, 0) |
This SQL statement would return 0 if the commission field contained a null value. Otherwise, it would return the commission field. |
Frequently Asked Questions
|
Question: |
Answer: |
|
I tried to use the NVL function through VB to access Oracle DB. To be precise, SELECT NVL(Distinct (emp_name),'AAA'),................ I got an oracle error when I use distinct clause with NVL, but when I remove distinct it works fine. |
It is possible to the use the DISTINCT clause with the NVL function. However, the DISTINCT must come before the use of the NVL function. For example: SELECT distinct NVL(emp_name, 'AAA') |
|
Is it possible to use the NVL function with more than one column with the same function call? To be clear, if i need to apply this NVL function to more than one column like this: NVL(column1;column2 ...... , here is the default value for all ) |
Answer: You will need to make separate NVL function calls for each column. For example: SELECT NVL(table_name, 'not found'), NVL(owner, 'not found') |
|
Examine the TRAINING table as given below: Name Null? Type TRAINING_ID NOT NULL NUMBER(5) Which two SQL would execute successfully? (Choose two)
|
A, D. Use NVL function to provide an alternate value to a column when NULL. |
使用DISTINCT 的方法COUNT函数和NVL函数的区别:
|
NVL |
SELECT DISTINCT NVL(emp_name, 'AAA') |
|
COUNT |
SELECT COUNT(DISTINCT department) AS "Unique departments" |
From <https://www.techonthenet.com/oracle/functions/nvl.php>
Oracle Function: NVL的更多相关文章
- Oracle Function:COUNT
Description The Oracle/PLSQL COUNT function returns the count of an expression. The COUNT(*) functio ...
- Oracle Function:TO_CHAR
Description The Oracle/PLSQL TO_CHAR function converts a number or date to a string.将数字转换为日期或字符串 Syn ...
- oracle中空值null的判断和转换:NVL的用法
1.NULL空值概念 数据库里有一个很重要的概念:空值即NULL.有时表中,更确切的说是某些字段值,可能会出现空值, 这是因为这个数据不知道是什么值或根本就不存在. 2.NULL空值判断 空值不等同于 ...
- 问题:oracle nvl;结果:Oracle中的NVL函数
Oracle中的NVL函数 (2012-11-30 13:21:43) 转载▼ 标签: nvl oracle 分类: Oracle Oracle中函数以前介绍的字符串处理,日期函数,数学函数,以及转换 ...
- oracle function学习1
oracle function学习基层: 函数就是一个有返回值的过程. 首先 知道oracle 使用限制: 函数调用限制: 1. SQL语句中只能调用存储函数(服务器端),而不能调用客户端 ...
- Oracle中的NVL函数
Oracle中函数以前介绍的字符串处理,日期函数,数学函数,以及转换函数等等,还有一类函数是通用函数.主要有:NVL,NVL2,NULLIF,COALESCE,这几个函数用在各个类型上都可以. 下面简 ...
- oracle中的nvl(), nvl2()函数
nvl()函数是oracle/plpgsql中的一个函数,格式为:nvl(string1, replace_with) 功能:如果string1 位null,那么nvl()函数返回replace_wi ...
- Oracle中的NVL,NVL2,NULLIF以及COALESCE函数使用
首先注意空(null)值,空值加任何值都是空值,空值乘任何值也都是空值,依此类推. 1.NVL函数 NVL函数的格式如下:NVL(expr1,expr2) 含义是:如果oracle第一个参数为空那么显 ...
- [转载]Oracle中的NVL函数
Oracle中函数以前介绍的字符串处理,日期函数,数学函数,以及转换函数等等,还有一类函数是通用函数.主要有:NVL,NVL2,NULLIF,COALESCE,这几个函数用在各个类型上都可以. 下面简 ...
随机推荐
- SELECT中常用的子查询操作
MySQL中的子查询 是在MySQL中经常使用到的一个操作,不仅仅是用在DQL语句中,在DDL语句.DML语句中也都会常用到子查询. 子查询的定义: 子查询是将一个查询语句嵌套在另一个查询语句中: 在 ...
- 利用BurpSuite实现半自动化盲注
为了方便演示,这里直接使用字符,构造SQL Payload: ?id= and substring(user(),,)='r' 1.使用Burp抓包,发送到Intruder,设置模式和变量 2.设置字 ...
- C#中的垃圾回收机制与delegate
在DeepStream的C#版本调试过程中,发现了一个问题,运行一段时间后,大概每次内存到16M(Debug模式)就会异常 错误“System.NullReferenceException:未将对象引 ...
- spine-unity3D 学习笔记
http://zh.esotericsoftware.com/spine-using-runtimes //skeletonData SkeletonAnimation skeletonAnimati ...
- 使用composer进行依赖管理:以guzzle为例
今天突然发现一个不错的php http客户端库guzzle,欣喜不已,跃跃欲试.打开guzzle文档,发现需要composer做依赖管理.之前没有接触过composer,正好以此学习下,也蛮好! 本文 ...
- SourceTree 全局忽略及相关问题
SourceTree 默认使用的是全局缓存配置, 这个配置文件在 SourceTree -> Preferences -> Git -> 全局忽略列表 点击 编辑文件 接下来输入相关 ...
- Cent OS 常用命令搜集
打开一个 Shadowsocks 配置文件nano /etc/shadowsocks.json 重启 Shadowsocks/etc/init.d/shadowsocks restart centos ...
- x64免签名驱动程序
DSEFix GitHub https://github.com/hfiref0x/DSEFix
- thinkphp5 URL的访问
ThinkPHP采用单一入口模式访问应用,对应用的所有请求都定向到应用的入口文件,系统会从URL参数中解析当前请求的模块.控制器和操作,下面是一个标准的URL访问格式: localhost/index ...
- 【云迁移论文笔记】Cloud Migration Research:A Systematic Review
Cloud Migration Research:A Systematic Review Author Info: Pooyan Jamshidi PhD Postdoctoral Researche ...