当行子查询返回多个行?

Snipaste_2020-05-22_11-13-17.png

想要做成的效果是搜索C_TYPE出第一个图,搜索EQPID出第二个图表

目前第一个图已经做出来了,如图

Snipaste_2020-05-22_11-16-42.png

别人发给我的SQL让我做图,我放到帆软里改成这样了,但是报错,不知道怎么改

select to_char(to_date(A.DAY,'yyyymmdd'),'yy-mm-dd') day,
                           nvl(oee,0) OEE,
                           least(round(actual_wph/peak_wph,3),2.0 + round(actual_wph/peak_wph,1)/100) wph_ratio,
                           (select to_number(b.oee) from pc.RPT_EQP_TYPE b ) oee_target,
                           (select to_number(b.WPH_ratio) from pc.RPT_EQP_TYPE b ) WPH_Ratio_target
                      from pc.rpt_tool_perf_sx a
                     where 1=1
                       and a.day > to_char(sysdate-32,'yyyymmdd')
                   ${if(len(eqpid) == 0,"","and a.eqpid = '" +eqpid+ "' ")}   
                  order by a.day


原始别人给我的sql


select to_char(to_date(A.DAY,'yyyymmdd'),'yy-mm-dd') day,

                           nvl(oee,0) OEE,

                           least(round(actual_wph/peak_wph,3),2.0 + round(actual_wph/peak_wph,1)/100) wph_ratio,

                           (select to_number(b.oee) from RPT_EQP_TYPE b where b.eqpid = :p42_eqpid) oee_target,

                           (select to_number(b.WPH_ratio) from RPT_EQP_TYPE b where b.eqpid = :p42_eqpid) WPH_Ratio_target

                      from rpt_tool_perf_sx a

                     where A.EQPid = :p42_eqpid

                       and a.day > to_char(sysdate-32,'yyyymmdd')

                  order by a.day


FineReport 吕爱慧 发布于 2020-5-22 11:15 (编辑于 2020-5-22 11:16)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
dobeyluLv4见习互助
发布于2020-5-22 11:25

这种一般都是sql没写好。。

  • 吕爱慧 吕爱慧(提问者) 对的,然后我不知道该改哪里
    2020-05-22 11:25 
  • dobeylu dobeylu 回复 吕爱慧(提问者) select to_char(to_date(A.DAY,\'yyyymmdd\'),\'yy-mm-dd\') day, nvl(oee,0) OEE, least(round(actual_wph/peak_wph,3),2.0 + round(actual_wph/peak_wph,1)/100) wph_ratio, (select to_number(b.oee) from pc.RPT_EQP_TYPE b ) oee_target, (select to_number(b.WPH_ratio) from pc.RPT_EQP_TYPE b ) WPH_Ratio_target from pc.rpt_tool_perf_sx a where 1=1 and a.day > to_char(sysdate-32,\'yyyymmdd\') ${if(len(eqpid) == 0,\"\",\"and a.eqpid = \'\" +eqpid+ \"\' \")} order by a.day 看这个语句嫌疑比较大的是least(round(actual_wph/peak_wph,3),2.0 + round(actual_wph/peak_wph,1)/100) wph_ratio, (select to_number(b.oee) from pc.RPT_EQP_TYPE b ) oee_target, (select to_number(b.WPH_ratio) from pc.RPT_EQP_TYPE b ) WPH_Ratio_target 这三个地方,你先注释这三个地方看看会不会报错,如果没有的话在一个个取消注释,多试几下就知道问题在哪了。
    2020-05-23 15:19 
  • 2关注人数
  • 386浏览人数
  • 最后回答于:2020-5-22 11:25
    请选择关闭问题的原因
    确定 取消
    返回顶部