PLSQL使用decode语法嵌套select

zhouwenhuan 2017-08-04 02:51:46
查询所有明细,取到最小时间,如果明细与最小时间相等,为1,不等,为0。
select decode(e.Recipeflag_Int,(select count(*) from t_opr_outpatientrecipe a where a.recorddate_dat between to_date('2017-08-03 00:00:00','yyyy-mm-dd hh24:mi:ss')and to_date('2017-08-03 23:59:59','yyyy-mm-dd hh24:mi:ss')and a.recorddate_dat=(select min(recorddate_dat) from t_opr_outpatientrecipe where a.registerid_chr=registerid_chr)=1),1,0)from t_opr_outpatientrecipe ed hh24:mi:ss')and to_date('2017-08-03 23:59:59','yyyy-mm-dd hh24:mi:ss')and a.recorddate_dat=(select min(recorddate_dat) from t_opr_outpatientrecipe where a.registerid_chr=registerid_chr)=1),1,0)from t_opr_outpatientrecipe e一直提示缺失右括号......网上不是说decode里面的select块要加()么,哪里不对啊?
...全文
817 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
imcmuc 2017-08-07
  • 打赏
  • 举报
回复
(select count(*) from t_opr_outpatientrecipe a where a.recorddate_dat between to_date('2017-08-03 00:00:00','yyyy-mm-dd hh24:mi:ss')and to_date('2017-08-03 23:59:59','yyyy-mm-dd hh24:mi:ss')and a.recorddate_dat=(select min(recorddate_dat) from t_opr_outpatientrecipe where a.registerid_chr=registerid_chr)=1),1,0)from t_opr_outpatientrecipe ed hh24:mi:ss')and to_date('2017-08-03 23:59:59','yyyy-mm-dd hh24:mi:ss')and a.recorddate_dat=(select min(recorddate_dat) from t_opr_outpatientrecipe where a.registerid_chr=registerid_chr)=1),1,0)from t_opr_outpa
js14982 2017-08-04
  • 打赏
  • 举报
回复
ed hh24:mi:ss') 这是一句什么???在你的form表后面

1,617

社区成员

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

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