oracle sql常用查询nvl,nvl2,decode区别及使用方法

1,NVL( E1, E2) 如果E1为NULL,则NVL函数返回E2的值,否则返回E1的值,如果两个参数都为NULL ,则返回NULL。

select nvl(null, 1) from dual; --
select nvl(2, 1) from dual; --
select nvl(null, null) from dual; --null

2,nvl2 (E1, E2, E3) 的功能为:如果E1为NULL,则函数返回E3,否则返回E2

select nvl2(null, 1, 3) from dual; --

,3,decode(E1, E2, E3, E4, E5, E6 ) 如果E1==E2,则值E3,如果E1==E4,则值E5;否则E5

select decode(1, 1, 2, 3, 4, 5) from dual; --
select decode(3, 1, 2, 3, 4, 5) from dual; --
select decode(2, 1, 2, 3, 4, 5) from dual; --

oracle之nvl,nvl2,decode的更多相关文章

  1. 浅析ORACLE中NVL/NVL2/DECODE/CASE WHEN的用法

    使用NVL的时候只能对值进行是否为空的判断,基本语法是NVL( 值1, ,结果2).它的功能是如果值1为空,则此函数返回结果2,不为空的话直接输出值1(如果两个参数都为空,那么还是返回空): NVL2 ...

  2. oracle通用函数,nvl,nvl2,NULLIF ,coalesce

    Oracle 通用函数 ① NVL 函数--------将空值转换成一个已知的值: 可以使用的数据类型有日期.字符.数字. 函数的一般形式:   NVL(commission_pct,0)       ...

  3. oracle函数nvl,nvl2的区别,nullif函数,coalesce函数

    在oracle中用nvl和nvl2函数来解决为空的情况,例如,如果奖金为空,则为它指定一个数.也就是nvl(奖金字段,指定的奖金),但是两个的类型要一致. 1)nvl()函数 SQL> sele ...

  4. COALESCE NVL NVL2 DECODE

    1 COALESCE 語法:COALESCE(expr1, expr2, ..., exprn) n>=2 作用:COALESCE returns the first non-null expr ...

  5. oracle函数nvl, nvl2, nullif

    nvl函数 语法: NVL(表达式1, 表达式2) select nvl(s.name, '未填写') from student s 如果表达式1的值为空, 则显示第二个值, 否则显示原来的值, nv ...

  6. 简单接触oracle数据库nvl函数decode函数

    SQL语句的DECODE()和NVL()函数用法 SELECT DECODE(choose_tool,0,'宝马',1,'电动车',2,'自行车','步行')  AS my_tool FROM dat ...

  7. oracle group by rollup,decode,grouping,nvl,nvl2,nullif,grouping_id,group_id,grouping sets,RATIO_TO

    干oracle 047文章12当问题,经验group by 声明.因此邂逅group by  rollup,decode,grouping,nvl,nvl2,nullif,RATIO_TO_REPOR ...

  8. oracle几个函数整理 DECODE() NVL NVL2 NULLIF Coalesce(转)

    DECODE() decode()函数简介: 主要作用:将查询结果翻译成其他值(即以其他形式表现出来,以下举例说明): 使用方法: Select decode(columnname,值1,翻译值1,值 ...

  9. SQL Fundamentals || Single-Row Functions || 通用函数 General function || (NVL,NVL2,NULLIF,DECODE,CASE,COALESCE)

    SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使用单 ...

随机推荐

  1. 2743711 - Possible Unexpected Results When Using Query With an ORDER BY Clause on a Rowstore Table With a Parallelized Search on a Cpbtree-Type Index

    2743711 - Possible Unexpected Results When Using Query With an ORDER BY Clause on a Rowstore Table W ...

  2. Computer Vision_33_SIFT:LIFT: Learned Invariant Feature Transform——2016

    此部分是计算机视觉部分,主要侧重在底层特征提取,视频分析,跟踪,目标检测和识别方面等方面.对于自己不太熟悉的领域比如摄像机标定和立体视觉,仅仅列出上google上引用次数比较多的文献.有一些刚刚出版的 ...

  3. Spark foreachpartiton和mappartition的异同

    相同 都是对分区进行操作 不同 1.foreachpartition是Action操作,mappartition是Transformation操作 2.foreachpartition无返回值,map ...

  4. Python语言程序设计:Lab5

    Programming Create a Class Student which should have the following information:Parameters passed to ...

  5. windows平台RSA密钥生成

    1.安装openssl工具 下载安装openssl工具,执行安装目录bin下的"openssl.exe",执行后会弹出命令窗口. 2.生成私钥 在命令窗口输入“genrsa -ou ...

  6. 《hello--world团队》第五次作业:项目需求分析改进与系统设计

    项目 内容 这个作业属于哪个课程 2016级计算机科学与工程学院软件工程(西北师范大学) 这个作业的要求在哪里 实验九 团队作业5-团队项目需求改进与系统设计 团队名称 <hello--worl ...

  7. archlinux 使用 postgresql

    一.安装与初始化 1.初始化数据目录 默认安装后已创建 postgres 系统用户 切换到 postgres 用户 $ sudo -iu postgres # Or su - postgres for ...

  8. js事件冒泡/捕获

  9. [Angular 8] Lazy loading with dynamic loading syntax

    @NgModule({ declarations: [AppComponent, HomeComponent], imports: [ BrowserModule, MatSidenavModule, ...

  10. 学到了林海峰,武沛齐讲的Day31 完 TCP UDP

    多用户链接 验证等.学习了思路.还是很有用的..