`

where中的case

 
阅读更多
1. 在选择列中的实例
select
  (case t.ca04_field_id
      when '1021' then '1021000'
      when '1022' then '1022000'
      else '7777'
      end) as field 
     
from ta_document15 t

2.在where条件中

由于case   when   只能返回值,不能返一个true   OR   false ,
所以在where条件中,可以采用下边的方法:
where  
(case XXX  when   A     then   1  
            when  B    then   2
            else   0  
end)=1



另,case+like的用法:
declare   @IsShow   Int
select   @IsShow=1

如是不同的操作符可用下面的方式
Select   *
From   SO
Where     (SONUM   =   case     @IsShow   When   1   Then     'D3990001 '     end   )     or   (SONUM   like     case         @IsShow   When   2     Then     'D3A370261 '     end   )

如是相同的操作符可用下面的方式
Select   *
From   SO
Where     SONUM   like   (   case     @IsShow   When   1   Then     'D3990001% '     When   2     Then     'D3A370261% '     end   )
分享到:
评论

相关推荐

    oracle where case when where后面跟case when

    NULL 博文链接:https://vernonchen163.iteye.com/blog/1908053

    SQL Server中Case 的不同用法

    CASE 可能是 SQL 中被误用最多的关键字之一。虽然你可能以前用过这个关键字来创建字段,但是它还具有更多用法。例如,你可以在 WHERE 子句中使用 CASE。本文将为大家介绍SQL Server中Case 的不同用法。

    Oracle_case_when_用法

    详细讲解了case、when的用法.ASE表达式可以在SQL中实现if-then-else型的逻辑,而不必使用PL/SQL。CASE的工作方式与DECODE()类似,但应该使用CASE,因为它与ANSI兼容。

    oracle case when 语句的用法详解

    1. CASE WHEN 表达式有两种形式 代码如下:–简单Case函数 CASE sex ... CASE WHEN 在语句中不同位置的用法2.1 SELECT CASE WHEN 用法 代码如下:SELECT grade, COUNT (CASE WHEN sex = 1 THEN 1 /*sex 1为男生,2位

    Oracle-Decode()函数和CASE语句的比较

    本文讲述了Oracle-Decode()函数和CASE语句的比较。

    Business Case Analysis with R

    The company must determine the value of making the decision to move forward and where they might prioritize their attention to make a more informed and robust decision. While the example used is a ...

    Exercise #1 ATM Use-case diagram

    construct the Automatic Teller Machine with the help of ‘Use-case diagram’, where you show the following things: Customer uses ATM machine:-  for balance inquiry  Cash Deposit/withdrawal/...

    sql 中 case when 语法使用方法

    没有,用case when 来代替就行了. 例如,下面的语句显示中文年月 代码如下: select getdate() as 日期,case month(getdate()) ...例如,你可以在 WHERE 子句中使用 CASE。 首先让我们看一下 CASE 的语法。在一般的 SELEC

    casewhen多条件oracle-casewhen(casewhen同时满足多条件).pdf

    casewhen多条件oracle-casewhen(casewhen同时满足多条件).pdf

    Python Machine Learning Case Studies 2017

    hands-on case study-based approach to crack real-world applications where machine learning concepts can provide a best fit. These smarter machines will enable your business processes to achieve ...

    Use Case Driven Object Modeling with UML_ Theory and Practice.pdf

    A Couple of Thoughts on Use Case Templates. . . . . . . . . . . . . . . . . . 74 Use Case or Algorithm?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Use Case Modeling in...

    SqlServer使用 case when 解决多条件模糊查询问题

    我们在进行项目开发中,经常会遇到多条件模糊...最近写数据库存储过程的时候经常使用case when 语句,正好可以用这个语句解决一下以上问题。以SQL中的NorthWind数据库为例,我要操作的是其中的Employees表,该表中默认

    (2008)A_Case-Based_Approach_for_Action_Selection_and_Coo

    work we propose the use of Case-Based Reasoning techniques to handle all these features in the action selection problem of a team of robots. Moreover, we are also interested in obtaining a cooperative...

    7-1 Build A Binary Search Tree.zip_13MV_6ST_Case File_Datastrctu

    For the i-th activity, three non-negative numbers are given: S[i], E[i], and L[i], where S[i] is the index of the starting check point, E[i] of the ending check point, and L[i] the lasting time of ...

    MySQL中使用case when 语句实现多条件查询的方法

    今天在一个应用中使用到了一个比较特殊的数据查询要求。需要的朋友可以参考下。

    MySQL中的if和case语句使用总结

    Mysql的if既可以作为表达式用,也可在存储过程中作为流程控制语句使用,如下是做为表达式使用: IF表达式 代码如下: IF(expr1,expr2,expr3) 如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的...

    code_hdu.rar_ACM_The First_hdu_test case example

    n)⊕n, where ``⊕’’ denotes the bitwise XOR operation. Please write a program to find the smallest positive integer n that (f(n,m)?n)⊕n=k, or determine it is impossible. Input The first line of ...

    oracle11g密码敏感取消

    --Oracle11g中Exp空表的问题:禁用插入数据时才分配空间功能 show parameter deferred_segment_creation alter system set deferred_segment_creation=false; -- 查找空表: select 'alter table '||table_name||'...

Global site tag (gtag.js) - Google Analytics