Oracle Apex查询错误 - ORA-01427:单行子查询返回多行

时间:2017-12-11 18:06:41

标签: sql oracle

select 
EQUIPMENT_OBJ_UID,
EQUIPMENT_CREATED_TIMESTAMP,
EQUIPMENT_CREATED_BY,
EQUIPMENT_NAME,
EQUIPMENT_STATUS,
EQUIPMENT_TYPE,
DESCRIPTION,
EQUIPMENT_OWNER,
SECONDARY_OWNER,
TERTIARY_OWNER, 
FACILITY, 
(select MAX(ENTER_STATE_TIMESTAMP) from EQUIP_STATE_HISTORY where EQUIP_STATE_HISTORY.EQUIPMENT = EQUIPMENT_NAME) as "LAST_STATE_CHANGE", 
(select EQUIP_STATE_HISTORY.CREATED_BY from EQUIP_STATE_HISTORY where EQUIP_STATE_HISTORY.EQUIPMENT = EQUIPMENT_NAME and ENTER_STATE_TIMESTAMP = (select MAX(ENTER_STATE_TIMESTAMP) from EQUIP_STATE_HISTORY where EQUIP_STATE_HISTORY.EQUIPMENT = EQUIPMENT_NAME)) as "LAST_STATE_CHANGE_USER",
(select count(EQP_ISSUE_OBJ_UID) from EQP_ISSUE_OBJ
where EQP_ISSUE_TOOL = EQUIPMENT_NAME
and EQP_ISSUE_STATUS != 'Closed' and EQP_ISSUE_STATUS != 'Cancelled') as "OPEN_ISSUES",
(select STATE_CHANGE_REASON from EQUIP_STATE_HISTORY where EQUIPMENT = EQUIPMENT_NAME and ENTER_STATE_TIMESTAMP = (select MAX(ENTER_STATE_TIMESTAMP) from EQUIP_STATE_HISTORY where EQUIPMENT = EQUIPMENT_NAME)) as "DOWN_REASON", 
(select MAX(EQUIPMENT_PM_LOG.CREATED_TIMESTAMP) from EQUIPMENT_PM_LOG where (ACTIVITY_TYPE = 'Light Bulb Change') and EQUIPMENT_PM_LOG.EQUIPMENT = EQUIPMENT_OBJ.EQUIPMENT_NAME) as "LAST_BULB_CHANGE", 
(select EQUIPMENT_PM_LOG.LIGHT_BULB_EXPECTED_HRS from EQUIPMENT_PM_LOG where 
ACTIVITY_TYPE = 'Light Bulb Change' and EQUIPMENT_PM_LOG.EQUIPMENT = EQUIPMENT_OBJ.EQUIPMENT_NAME and 
EQUIPMENT_PM_LOG.CREATED_TIMESTAMP = (select MAX(EQUIPMENT_PM_LOG.CREATED_TIMESTAMP) from EQUIPMENT_PM_LOG where ACTIVITY_TYPE = 'Light Bulb Change' and EQUIPMENT_PM_LOG.EQUIPMENT = EQUIPMENT_OBJ.EQUIPMENT_NAME)) as "LIGHT_BULB_EXPECTED_HRS" 
from EQUIPMENT_OBJ 

以上查询在SQL命令中运行时工作正常但是给出错误ORA-01427:单行子查询在Oracle apex应用程序交互式报告中返回多行 请帮忙,感谢任何帮助。

0 个答案:

没有答案