我是编码新手,正在准备一个 SQL 命令,但卡在了一步。下面是主要的 SQL 查询:
select
distinct
hap.position_code as RequisitionNumber,
COALESCE(hap.attribute10,'UNIVERSAL') as RequisitionType, hap.name as
RequisitionTitle,
paam1.job_id as RequisitionTemplate, COALESCE(hap.attribute11,'1') as
NumberToHire,
pu.username as HiringManagerLogin,
paam1.job_id as JobField,
hap.full_part_time as Schedules, hap.position_code as PositionCode
from hr_all_positions hap, per_all_assignments_m paam1, per_users pu
where hap.position_id = paam1.position_id
and hap.position_id in
(
select distinct paam.position_id from per_all_assignments_m paam,
per_periods_of_service ppos
where paam.person_id = ppos.person_id and paam.position_id is not null and
ppos.actual_termination_date >= sysdate
)
在上面的查询中,我从下面附加的另一个查询中获取 pu.username 的值:
select pu.username from per_users pu where person_id = (
select pmhd.manager_id from PER_MANAGER_HRCHY_DN pmhd,
per_periods_of_service ppos
where pmhd.person_id = ppos.person_id and pmhd.IMMEDIATE_REPORTEE_ASG_ID is
not null
and pmhd.EFFECTIVE_END_DATE = ppos.actual_termination_date and
ppos.actual_termination_date >= sysdate
and pmhd.person_id = (select distinct paam.person_id from
per_all_assignments_m paam, per_periods_of_service ppos
where paam.person_id = ppos.person_id and paam.position_id is not null and
ppos.actual_termination_date >= sysdate)
)
现在,当我加入两个查询时,如下所示:
select
distinct
hap.position_code as RequisitionNumber,
COALESCE(hap.attribute10,'UNIVERSAL') as
RequisitionType, hap.name as RequisitionTitle,
paam1.job_id as RequisitionTemplate, COALESCE(hap.attribute11,'1') as
NumberToHire,
pu.username as HiringManagerLogin,
paam1.job_id as JobField,
hap.full_part_time as Schedules, hap.position_code as PositionCode
from hr_all_positions hap, per_all_assignments_m paam1, per_users pu
where hap.position_id = paam1.position_id and paam1.person_id = pu.person_id
and pu.person_id = (
select pmhd.manager_id from PER_MANAGER_HRCHY_DN pmhd, per_periods_of_service
ppos
where pmhd.person_id = ppos.person_id and pmhd.IMMEDIATE_REPORTEE_ASG_ID is
not null
and pmhd.EFFECTIVE_END_DATE = ppos.actual_termination_date and
ppos.actual_termination_date >= sysdate
and pmhd.person_id = (select distinct paam.person_id from
per_all_assignments_m
paam, per_periods_of_service ppos
where paam.person_id = ppos.person_id and paam.position_id is not null and
ppos.actual_termination_date >= sysdate)
)
and hap.position_id in
(
select distinct paam.position_id from per_all_assignments_m paam,
per_periods_of_service ppos
where paam.person_id = ppos.person_id and paam.position_id is not null and
ppos.actual_termination_date >= sysdate
)
我正在尝试这是Oracle 数据库 没有数据输出来了,我不明白为什么?
请帮我 !!
在此先感谢, 希瓦姆