zoukankan      html  css  js  c++  java
  • oracle方法

    decode('1',
    '1','第1季度',
    '2','第2季度',
    '3','第3季度',
    '4','第4季度',
    '')   相当于判断

    select instr('helloworld','wo') from dual; --返回结果:6    即“w”开始出现的位置  定位返回值 

    ORACLE WITH AS 用法

    with TT as(

    select 2019 as year ,decode('1',
    '1',
    '第1季度',
    '2',
    '第2季度',
    '3',
    '第3季度',
    '4',
    '第4季度',
    '') as jd
    from dual
    )


    select * from TT

    with para as
    (select 2019 year, '1' jd from dual)

    select (case t1.jd
    when '1' then
    t1.year || '03'
    when '2' then
    t1.year || '06'
    when '3' then
    t1.year || '09'
    else
    t1.year || '12'
    end) end_month
    from para t1

     NVL(Expr1,Expr2)如果Expr1为NULL,返回Expr2的值,否则返回Expr1的值

    instr(:orgcode, to_char(t.aaa027)) > 0

    with para as
    (select 2019 year, '1' jd from dual),
    get_month as (

    select (case t1.jd
    when '1' then
    t1.year || '03'
    when '2' then
    t1.year || '06'
    when '3' then
    t1.year || '09'
    else
    t1.year || '12'
    end) end_month
    from para t1
    )

    (select * from para)

    with as语法
    相当于建了个临时表 ,或者sql的别命名

      1.  
        with
      2.  
        tmp1 as(select * from aa where id="001"),
      3.  
        tmp2 as(select * from bb where id="001"),
      4.  
        tmp3 as(select* from cc where id="001"),
      5.  
        ...select *from tmp1 ,  tmp2,tmp3 ... where tmp1.id=tmp2.id=tmp3.id='001'  ;
      6.  
        --相当于
      7.  
        create table  tmp1  as  select * from aa
      8.  
         
      9.  
        create table  tmp2  as  select * from bb
      10.  
         
      11.  
        create table  tmp3  as  select * from cc
      12.  
         
      13.  
        select * from tmp1  ,tmp2,tmp3 where tmp1.id=tmp2.id=tmp3.id='001'  ;
  • 相关阅读:
    7-2 一元多项式的乘法与加法运算 (20 分)
    cvc-complex-type.2.4.a: Invalid content was found starting with element(servlet)
    MOOC 2.3 队列
    MOOC 2.2 堆栈
    MOOC 2.1 线性表及其实现
    MOOC 1.3 最大子列和
    计时程序
    MOOC 1.1 什么是数据结构
    poj3253
    二分法查找——对数
  • 原文地址:https://www.cnblogs.com/zzl0916/p/13797866.html
Copyright © 2011-2022 走看看