• 如何在SQL CASE表达式中返回多个值


    Oracle数据库开发中CASE...THEN子句有时需要返回多个值用于判断,如何做才能在CASE...THEN表达式中返回多个值呢,具体参考下面的演示:
    SQL> select case
      2           when to_char(sysdate, 'SS') > 30 then sys.odcivarchar2list('Sent')
      3           else sys.odcivarchar2list('New', 'Sent')
      4         end options
      5    from dual;
    
    OPTIONS
    --------------------------------------------------------------------------------
    ODCIVARCHAR2LIST('Sent')
    
    SQL> /
    
    OPTIONS
    --------------------------------------------------------------------------------
    ODCIVARCHAR2LIST('New', 'Sent')
    SQL> select *
      2    from table(
      3            select case when to_char(sysdate,'SS') > 30 then sys.odcivarchar2list('Sent')
      4                        else sys.odcivarchar2list('New','Sent')    
      5                   end options
      6            from dual
      7              );
    
    COLUMN_VALUE
    --------------------------------------------------------------------------------
    New
    Sent
    SQL> /
    
    COLUMN_VALUE
    --------------------------------------------------------------------------------
    Sent
    SQL> select *
    from emp
    where report_status in 
    (
    select *
    from table(
    select
    case
    when to_char(sysdate,'SS') > 30 then sys.odcivarchar2list('Sent')
    else sys.odcivarchar2list('New','Sent')
    end options
    from dual
    )
    ) ;

  • 相关阅读:
    Sqlserver日期函数应用
    SSRS匿名访问
    SSAS动态添加分区(一)
    BI就是报表?
    CreateEvent函数/多线程/c++
    字符编码介绍
    Win7 64下Visual C++ 6.0不兼容
    Winpcap安装,Cannot open include file 'pcap.h'
    PPT开发 * .pps 文件类型
    Visual Assist X 工具栏不显示 toolbar
  • 原文地址:https://www.cnblogs.com/alen-liu-sz/p/12975727.html
Copyright © 2020-2023  润新知