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'  ;
  • 相关阅读:
    SSH批量部署服务
    rsync配置
    你到底有没有资本
    QT4.8.5 源码编译记录
    kernel 4.4.12 移植 HUAWEI MU609 Mini PCIe Module
    AM335x 添加 HUAWEI MU609 Mini PCIe Module,并用pppd 启动相关设备
    u-boot bootz 加载kernel 流程分析
    Linux kernel 之 socket 创建过程分析
    Linux kernel 之 uart 驱动解析
    am335x 无屏实现开关机程序
  • 原文地址:https://www.cnblogs.com/zzl0916/p/13797866.html
Copyright © 2011-2022 走看看