早教吧作业答案频道 -->数学-->
mysql的casewhen语句转oraclewhere子句条件如下:wherea.xxx='asdf'and(casewhen(b.ilike'%0%')thentruewhen(b.ilike'%1%')thenc.creatorCode=#code#when(b.ilike'%2%')then(d.createDept=#dept#and#flag#=1)elsefalseend)
题目详情
mysql的case when语句转oracle
where子句条件如下:
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then true
when (b.i like '%1%') then c.creatorCode = #code#
when (b.i like '%2%') then (d.createDept = #dept# and #flag# = 1)
else false
end
)
这语句是改过,以免泄漏公司业务,只表示逻辑上是这个意思.
like让人有些无奈,b.i可以012都有,显然逻辑是如果有0,不管是否有1,2,用条件1判断,没有0,但有1,则用条件2,0,1都没有但有2,则用条件3.
where子句条件如下:
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then true
when (b.i like '%1%') then c.creatorCode = #code#
when (b.i like '%2%') then (d.createDept = #dept# and #flag# = 1)
else false
end
)
这语句是改过,以免泄漏公司业务,只表示逻辑上是这个意思.
like让人有些无奈,b.i可以012都有,显然逻辑是如果有0,不管是否有1,2,用条件1判断,没有0,但有1,则用条件2,0,1都没有但有2,则用条件3.
▼优质解答
答案和解析
oracle也有case when的语法,照办就行,不过用在where条件中,需要有返回值的比较.
这是根据你提供的语句修改,给你提供一个参考吧:
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then true
when (b.i like '%1%') and c.creatorCode = #code# then true
when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then true
else false
end) = true
这是按照我的业务理解写的
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then 1
when (b.i like '%1%') and c.creatorCode = #code# then 2
when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then 3
else 4
end) = 1 -- (根据反回结果来过滤数据)
这是根据你提供的语句修改,给你提供一个参考吧:
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then true
when (b.i like '%1%') and c.creatorCode = #code# then true
when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then true
else false
end) = true
这是按照我的业务理解写的
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then 1
when (b.i like '%1%') and c.creatorCode = #code# then 2
when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then 3
else 4
end) = 1 -- (根据反回结果来过滤数据)
看了 mysql的casewhen...的网友还看了以下:
请教一个排列组合问题:20件产品中,有15件正品,5件次品.从中抽取3件,问至少有一件次品的概率. 2020-06-03 …
已知:7天卖了10台冰箱,问中位数多少条件1,每天至少卖1台条件2,每天最多卖两台A:单独由条件( 2020-06-07 …
组装甲、乙、丙3种产品,需用A、B、C3种零件.每件甲需用A、B各2个;每件乙需用B、C各1个;每 2020-07-09 …
mysql的casewhen语句转oraclewhere子句条件如下:wherea.xxx='as 2020-07-17 …
1.某车间有工作86人,若每人每天可加工A种零件15个,或B种零件12个或C种零件9个,怎样安排加 2020-07-17 …
A、B、C三种零件共153个,每人加工1个A零件都需3分钟,加工1个B零件都需5分钟,加工1个C零 2020-07-18 …
下列四个命题:①对立事件一定是互斥事件;②若A,B为两个事件,则P(A∪B)=P(A)+P(B);③ 2020-12-01 …
下列命题正确的是①必然事件的概率等于1②某事件的概率等于1.1③互斥事件一定是对立事件④对立事件一定 2020-12-01 …
软考基础知识题~unix中的文件系统采用(1).文件系统中用(2)管理文件.为了允许不同用户的文件具 2020-12-14 …
12件产品中,有5件一等品,4件二等品,3件三等品.从中取6件各种等级产品都有入选有几种选法答案是8 2021-01-02 …