缺失关键字

luoxudong121316 2011-08-10 09:23:41
select * from rfid_v_records t where gxsj = to_date('2011-1-1','yyyy-MM-dd')
and
case
when substr(licenseplate,length(licenseplate),length(licenseplate)+1) in('1','3','5','7','9')
then mod(to_number(substr(licenseplate,length(licenseplate),length(licenseplate)+1)),2)(这里缺失关键字)=1
end
...全文
223 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
opps_zhou 2011-08-10
  • 打赏
  • 举报
回复
有两点不明白
1. 你 case when 放在 where 条件以后,你的各个分支,实际就是一种满足条件的匹配形式,那么你可以简洁的写成
where (条件1(第一个 when then) or 条件2(第二个 when then))
2. 你非要写成 case when 也没有问题,但是你最后必须是一个条件判断形势
所以你需要将 case when 用一个()包含起来,然后将所有允许的返回值进行判断,例如
where (case when 条件1 then 返回值1
when 条件2 then 返回值2
end) in (返回值1, 返回值2)
luoxudong121316 2011-08-10
  • 打赏
  • 举报
回复
to opps_zhou
是这样的
select * from rfid_v_records t where gxsj = to_date('2011-1-1','yyyy-MM-dd')
and
case
when substr(licenseplate,length(licenseplate),length(licenseplate)+1) in('1','3','5','7','9')
then mod(to_number(substr(licenseplate,length(licenseplate),length(licenseplate)+1)),2)(这里缺失关键字)=1
when 另一种情况 then 返回值
when 另一种情况 then 返回值
end
opps_zhou 2011-08-10
  • 打赏
  • 举报
回复
你最好完成形式是这样的吗? and (case when end) = ?
luoxudong121316 2011-08-10
  • 打赏
  • 举报
回复
我那里省略了一下when then
opps_zhou 2011-08-10
  • 打赏
  • 举报
回复
你这个写法是不是有问题?

where gxsj = to_date('2011-1-1','yyyy-MM-dd')
and substr(licenseplate,length(licenseplate),length(licenseplate)+1) in('1','3','5','7','9')
and mod(to_number(substr(licenseplate,length(licenseplate),length(licenseplate)+1)),2) = 1

这样写 where 条件不是一样满足要求吗
luoxudong121316 2011-08-10
  • 打赏
  • 举报
回复
没明白,不过还谢谢了
tulang729 2011-08-10
  • 打赏
  • 举报
回复
楼上说的比较有理,支持!

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧