查询所有明细,取到最小时间,如果明细与最小时间相等,为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块要加()么,哪里不对啊?

解决方案 »

  1.   

    ed hh24:mi:ss')
    这是一句什么???在你的form表后面
      

  2.   

    (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