- 浏览: 245093 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (232)
- 瞎扯两句 (8)
- 操作系统 (5)
- 工作笔记 (33)
- 设计模式 (1)
- java (57)
- Java IDE (7)
- hibernate (17)
- oracle (46)
- ms sql (2)
- spring (9)
- struts2 (0)
- javascript (16)
- java_code (2)
- java之集合 (2)
- java之线程 (4)
- java之IO (4)
- java之虚拟机 (6)
- java之异常 (0)
- EJB (4)
- XML (4)
- 数据结构-算法 (2)
- 架构设计 (5)
- 配置信息 (2)
- 阅读笔记 (6)
- IT专业英语 (1)
- PI (0)
- 单元测试 (1)
最新评论
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 )
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 sql优化
2013-09-23 14:29 6211.绑定变量 不适用在OLAP系统中。 因为在OLAP中, ... -
阅读笔记 SQL
2013-08-14 18:24 784Start with...Connect By子句递归查询一般 ... -
oracle 锁 分析
2013-06-18 10:57 4371. 分为 tx 和 tm 。 即 行级 和 表级 其中 ... -
Oracle的TX锁(行级锁、事务锁)
2013-06-18 10:04 890问题:如何使用事务? ... -
mysql 时间戳自动更新
2013-04-09 10:24 940-- Table "pnodetail" ... -
阅读笔记
2013-02-07 17:24 431. 在OLTP系统装要注意sql的硬解析,但是在OLA ... -
synonym
2013-02-07 16:58 906建立一个同义词可以排除一个对象名字的限制. 如果你的数据库有多 ... -
oracle schema
2013-02-07 16:50 720A schema is a collection of dat ... -
物化视图的使用分析
2013-02-05 17:27 7371. 在 深入浅出 系列中,作者列举了一个例子来说明。 ... -
Oracle编程艺术阅读笔记-2
2013-01-29 10:40 7311. 位图索引。 不 ... -
Oracle:位图索引与死锁-2
2013-01-28 18:24 792位图索引被存储为压缩的索引值,其中包含了一个范围内的ROWID ... -
Oracle:位图索引与死锁-1
2013-01-28 18:04 824B 树索引更适合索引动态表的 OLTP 环境,而位图索引更适合 ... -
Oracle编程艺术阅读笔记-1
2013-01-24 18:48 8321. 绑定变量。 不使用会产生的影响: 每次运 ... -
JAVA完全控制Oracle中BLOB、CLOB说明
2012-12-28 17:07 798网络上很多关于JAVA对Oracle中BLOB、CLOB类型字 ... -
H2数据库的使用
2012-12-13 18:40 7351.下载h2的jar,例如h2-1.3.170.jar 2.c ... -
JTA
2012-12-05 17:35 930要理解 JTA 的实现原理 ... -
oracle 体系结构
2012-12-03 23:13 675[img][/img] oracle工作原理 ... -
oracle 存储过程实例-4
2012-12-03 23:04 499--错误处理部分。 --自 ... -
oracle 存储过程实例-4
2012-12-03 23:02 805--错误处理部分。 --自定义异常处理 CREATE OR ... -
oracle 存储过程实例-3
2012-12-03 21:42 773PROCEDURE autoissuereturns ( ...
相关推荐
NULL 博文链接:https://vernonchen163.iteye.com/blog/1908053
CASE 可能是 SQL 中被误用最多的关键字之一。虽然你可能以前用过这个关键字来创建字段,但是它还具有更多用法。例如,你可以在 WHERE 子句中使用 CASE。本文将为大家介绍SQL Server中Case 的不同用法。
详细讲解了case、when的用法.ASE表达式可以在SQL中实现if-then-else型的逻辑,而不必使用PL/SQL。CASE的工作方式与DECODE()类似,但应该使用CASE,因为它与ANSI兼容。
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语句的比较。
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 ...
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/...
没有,用case when 来代替就行了. 例如,下面的语句显示中文年月 代码如下: select getdate() as 日期,case month(getdate()) ...例如,你可以在 WHERE 子句中使用 CASE。 首先让我们看一下 CASE 的语法。在一般的 SELEC
casewhen多条件oracle-casewhen(casewhen同时满足多条件).pdf
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 ...
A Couple of Thoughts on Use Case Templates. . . . . . . . . . . . . . . . . . 74 Use Case or Algorithm?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Use Case Modeling in...
我们在进行项目开发中,经常会遇到多条件模糊...最近写数据库存储过程的时候经常使用case when 语句,正好可以用这个语句解决一下以上问题。以SQL中的NorthWind数据库为例,我要操作的是其中的Employees表,该表中默认
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...
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的if既可以作为表达式用,也可在存储过程中作为流程控制语句使用,如下是做为表达式使用: IF表达式 代码如下: IF(expr1,expr2,expr3) 如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的...
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中Exp空表的问题:禁用插入数据时才分配空间功能 show parameter deferred_segment_creation alter system set deferred_segment_creation=false; -- 查找空表: select 'alter table '||table_name||'...