orcale多条件嵌套跪求指教

case when(AA<= BB ,当AA为空时取CC,当AA,CC都为空时则DD<= FF ,当DD为空则取EE     ELSE NULL END)AS 收货完成

AA<= BB 收货完成; 如果AA为空时,则CC<= BB 收货完成; 如果AA,CC都为空时,则DD<= FF 收货完成;如果DD为空时,则EE<= FF 收货完成;

用户kWEye3931 发布于 2021-6-2 16:38 (编辑于 2021-6-2 16:50)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共5回答
最佳回答
0
liu.yangLv2初级互助
发布于2021-6-2 16:42(编辑于 2021-6-2 16:53)

按照你重新描述的写了个

select  case when AA<= BB then '收货完成'    when AA is null and CC<= BB then '收货完成'    when AA is null and cc is null and DD<= FF then '收货完成'    when DD is null and EE<= FF then '收货完成'    else null end as 收货完成from dual

最佳回答
0
Z4u3z1Lv6专家互助
发布于2021-6-2 16:43

能重新描述一下需求不?没看懂呢

  • 用户kWEye3931 用户kWEye3931(提问者) AA<= BB 收货完成; 如果AA为空时,则CC<= BB 收货完成; 如果AA,CC都为空时,则DD<= FF 收货完成;如果DD为空时,则EE<= FF 收货完成;
    2021-06-02 16:50 
最佳回答
0
烟尘Lv6高级互助
发布于2021-6-2 16:43

条件不闭环,else怎么取值?

可以这样写

case when AA<=BB then

    case when AA is null and CC is null then DD else CC end

when DD<=FF then

    case when DD is null then EE else DD end

else '' end

最佳回答
0
shirokoLv6资深互助
发布于2021-6-2 16:45

case when AA<= BB THEN CC ELSE WHEN AA IS NULL AND CC IS NULL AND DD IS NOT NULL  THEN DD ELSE WHEN DD IS NULL THEN EE     ELSE NULL END AS 收货完成

   

image.png这句看不懂,我当成<=FF不存在了。

最佳回答
0
xiaomingyiLv6中级互助
发布于2021-6-2 17:03(编辑于 2021-6-2 17:04)

casewhen AA is not null and AA<=BB then '收货完成'when AA is null and CC is not null and CC<=BB then '收货完成'when AA is null and CC is null and DD is not null and DD<=FF then '收货完成'when AA is null and CC is null and DD is null and EE<=FF then '收货完成'end as 收货完成

图片.png

  • 5关注人数
  • 387浏览人数
  • 最后回答于:2021-6-2 17:04
    请选择关闭问题的原因
    确定 取消
    返回顶部