寻找错误的解决方法
ORA-01427单行子查询返回多行
我正在使用这个SQL代码。这是我的水晶报告中的一个命令,我将错误缩小到了。但是此代码中有多个子查询,我无法找到解决此错误的最佳方法。我知道这种类型的错误通常与使用' ='在一个子查询的select语句中,我应该使用另一个如IN,LIKE等。任何建议都会有所帮助。
谢谢,
SELECT
JREQ.HRORGANIZATION,
JREQ.JOBREQUISITION AS "Req #",
cmdPoolRef."Pool Req Ref" AS "Candidate Pool",
cmdDualPostingRef."Dual Posting Ref" AS "Dual Posting Ref",
DEPTNAME.DESCRIPTION AS "Department Name",
JOB.DESCRIPTION AS "Job Title",
JREQ.OPENDATE AS "Date Opened",
CASE JREQ.STATUS
WHEN 1 THEN 'Pending'
WHEN 2 THEN 'Open'
WHEN 3 THEN 'On Hold'
WHEN 4 THEN 'Cancelled'
WHEN 5 THEN 'Filled'
WHEN 7 THEN 'Draft'
WHEN 8 THEN 'Approval Requested'
ELSE CONCAT('Unknown',JREQ.STATUS)
END AS "Req Status",
cmdFTELimited."FTE Limted" AS "FTE",
JREQ.INITIALOPENINGS AS "# of Positions",
JREQ.FILLEDOPENINGS AS "# of Positions Filled",
DEPTNAME.SHORTDESCRIPTION AS "Cost Center",
JREQ.REASONFOROPENING AS "Req Reason Code",
cmdEmpReplacing."Replacement ID" AS "Replacement ID",
cmdEmpReplacing."Replacement Name" AS "Replacement Name",
JREQ."UNION" AS "Union",
DEPT_LOCATION.DESCRIPTION AS "Location",
JREQ.SALARYSTRUCTURE AS "Family",
POS.SALARYSTRUCTUREGRADE AS "Grade",
TRIM(RECRUITER.PRESENTATIONNAMESNAPSHOT) AS "Recruiter Name",
TRIM(HIREMGR.PRESENTATIONNAMESNAPSHOT) AS "Hiring Manager",
cmdApptType."Appt Type" AS "Appointment Type",
JREQ.CATEGORY AS "Category",
cmdCandidateHired."Person Hired" AS "Person Hired",
cmdCandidateHired."Start Date" AS "Start Date",
cmdCandidateHired."Offer Amount" AS "Offer Amount",
VW.ENTITYORGUNIT
FROM LTMPROD.JOBREQUISITION JREQ
LEFT OUTER JOIN LTMPROD.HRORGANIZATIONUNIT DEPTNAME ON JREQ.HRORGANIZATIONUNIT = DEPTNAME.HRORGANIZATIONUNIT
LEFT OUTER JOIN LTMPROD.HRLOCATION DEPT_LOCATION ON JREQ.LOCATION = DEPT_LOCATION.HRLOCATION
LEFT OUTER JOIN LTMPROD.EMPLOYEE RECRUITER ON JREQ.RECRUITER = RECRUITER.EMPLOYEE
LEFT OUTER JOIN LTMPROD.POSITION POS ON JREQ.POSITION = POS.POSITION
LEFT OUTER JOIN LTMPROD.EMPLOYEE HIREMGR ON JREQ.HIRINGMANAGER = HIREMGR.EMPLOYEE
LEFT OUTER JOIN LTMPROD.JOB ON POS.JOB = JOB.JOB
LEFT OUTER JOIN LTMPROD.XXX_ORGUNIT_ENTITY_VIEW VW ON JREQ.HRORGANIZATIONUNIT = VW.HRORGANIZATIONUNIT
LEFT OUTER JOIN (
SELECT TO_NUMBER(UFS.ALPHA) AS "ReplaceThisEmp",
UFS.UFSUNIQUEID,
REPLACETHISEMPLOYEE.EMPLOYEE AS "Replacement ID",
TRIM(REPLACETHISEMPLOYEE.PRESENTATIONNAMESNAPSHOT) AS "Replacement Name"
FROM LTMPROD.USERFIELD_STORAGE UFS
LEFT OUTER JOIN LTMPROD.EMPLOYEE REPLACETHISEMPLOYEE ON TO_NUMBER(UFS.ALPHA) = REPLACETHISEMPLOYEE.EMPLOYEE
WHERE UFS.UFSCLASSNAME = 'JobRequisition'
AND UFS.UFSFIELDNAME = 'EmployeeReplacingID'
) cmdEmpReplacing ON cmdEmpReplacing.UFSUNIQUEID = JREQ.UNIQUEID
LEFT OUTER JOIN (
SELECT JA.JOBREQUISITION,
JA.EMPLOYMENTSTARTDATE AS "Start Date",
JA.SALARY AS "Offer Amount",
TRIM(CAN.PRESENTATIONNAMESNAPSHOT) AS "Person Hired"
FROM LTMPROD.JOBAPPLICATION JA
LEFT OUTER JOIN LTMPROD.CANDIDATE CAN ON CAN.CANDIDATE = JA.CANDIDATE
WHERE JA.SELECTIONPROCESS = 9
) cmdCandidateHired ON cmdCandidateHired.JOBREQUISITION = JREQ.JOBREQUISITION
LEFT OUTER JOIN (
SELECT UFS.ALPHA AS "Appt Type", UFS.UFSUNIQUEID
FROM LTMPROD.USERFIELD_STORAGE UFS
WHERE UFS.UFSCLASSNAME = 'JobRequisition'
AND UFS.UFSFIELDNAME = 'AppointmentType'
) cmdApptType ON cmdApptType.UFSUNIQUEID = JREQ.UNIQUEID
LEFT OUTER JOIN (
SELECT UFS.ALPHA AS "Pool Req Ref", UFS.UFSUNIQUEID
FROM LTMPROD.USERFIELD_STORAGE UFS
WHERE UFS.UFSCLASSNAME = 'JobRequisition'
AND UFS.UFSFIELDNAME = 'PoolRequistionReference'
) cmdPoolRef ON cmdPoolRef.UFSUNIQUEID = JREQ.UNIQUEID
LEFT OUTER JOIN (
SELECT UFS.ALPHA AS "Dual Posting Ref", UFS.UFSUNIQUEID
FROM LTMPROD.USERFIELD_STORAGE UFS
WHERE UFS.UFSCLASSNAME = 'JobRequisition'
AND UFS.UFSFIELDNAME = 'DualPostingReference'
) cmdDualPostingRef ON cmdDualPostingRef.UFSUNIQUEID = JREQ.UNIQUEID
LEFT OUTER JOIN (
SELECT UF.ALPHA AS "FTE Limted",UF.UFSUNIQUEID
FROM LTMPROD.USERFIELD_STORAGE UF
WHERE UF.UFSCLASSNAME = 'JobRequisition'
AND UF.UFSFIELDNAME = 'FTELimited'
) cmdFTELimited ON cmdFTELimited.UFSUNIQUEID = JREQ.UNIQUEID
答案 0 :(得分:0)
注意:Crystal Report可能产生此错误不是由于上述查询,而是您在报告中可能使用的其他查询,例如动态参数? 检查报告中使用的所有其他查询,正如您所提到的,它是oracle期望一条记录并获得更多的地方:通常是(=(选择...))