我正在处理一个选择以下信息的视图。 我遇到的问题是单行子查询返回多行。但是,我无法看清问题是什么。任何建议都会有所帮助
CREATE OR REPLACE VIEW eqx_dir_ind_rep_emp_v (person_id,
supervisor_id,
employee_name,
supervisor_name
)
AS
SELECT paf.person_id, paf.supervisor_id,
(SELECT full_name employee_name
FROM per_people_f
WHERE person_id = paf.person_id
AND SYSDATE BETWEEN effective_start_date AND effective_end_date)
employee_name,
(SELECT full_name supervisor_name
FROM per_people_f
WHERE person_id = supervisor_id
AND SYSDATE BETWEEN effective_start_date AND effective_end_date)
supervisor_name
FROM apps.per_all_assignments_f paf
答案 0 :(得分:0)
尝试添加以下内部选择语句。
CREATE OR REPLACE VIEW eqx_dir_ind_rep_emp_v (person_id,
supervisor_id,
employee_name,
supervisor_name
)
AS
SELECT paf.person_id, paf.supervisor_id,
(SELECT full_name employee_name
FROM per_people_f
WHERE person_id = paf.person_id
AND SYSDATE BETWEEN effective_start_date AND effective_end_date
AND rownum = 1)
employee_name,
(SELECT full_name supervisor_name
FROM per_people_f
WHERE person_id = supervisor_id
AND SYSDATE BETWEEN effective_start_date AND effective_end_date
AND rownum = 1)
supervisor_name
FROM apps.per_all_assignments_f paf