gpt4 book ai didi

sql - ORA-00913 : too many values in oracle subquery

转载 作者:行者123 更新时间:2023-12-02 00:30:46 26 4
gpt4 key购买 nike

我需要捕获所有提供给候选人的工作机会,以及候选人最终被录用的职位。我创建了两个单独的查询,一个捕获所有的工作机会,一个子查询只捕获每个候选人最终被录用的工作。当我合并这两个查询时出现问题,我得到 ORA-00913:值太多。有什么建议吗?

SELECT DISTINCT h.pi_candidate_num,
h.parent_pi_number,
h.associate_name,
j.job_family_name,
j.organization_name,
j.title,
e.contest_number,
e.pi_his_itm_app_trk_creation_dt offer_date
FROM wc_hired_interns_fa h
INNER JOIN wc_application_event_f e
ON h.pi_candidate_num = e.pi_candidate_num
INNER JOIN wc_job_information_d j
ON e.job_info_row_wid = j.row_wid
WHERE e.pi_his_itm_app_trk_creation_dt IN
(SELECT DISTINCT e.pi_his_itm_app_trk_creation_dt
FROM wc_application_event_f e
INNER JOIN wc_hired_interns_fa h
ON h.pi_candidate_num = e.pi_candidate_num
INNER JOIN wc_job_information_d j
ON e.job_info_row_wid = j.row_wid
WHERE j.job_family_name IN ('MDP', 'ELP', 'Emerging Leader Program', 'Other')
AND e.pi_his_itm_app_trk_sts_name = 'Extended'
AND e.pi_his_itm_app_trk_step_name = 'Offer'
AND j.title NOT IN ('Student Ambassador Program for Eligible Summer Interns', 'Student Ambassador'))
AND j.title IN (SELECT *
FROM (SELECT DISTINCT j.title full_time_detail,
rank() over(PARTITION BY e.pi_candidate_num ORDER BY e.pi_his_itm_app_trk_creation_dt DESC) AS rowrank
FROM wc_hired_interns_fa h
INNER JOIN wc_application_event_f e
ON h.pi_candidate_num = e.pi_candidate_num
INNER JOIN wc_job_information_d j
ON e.job_info_row_wid = j.row_wid
AND j.job_family_name IN ('MDP', 'ELP', 'Emerging Leader Program', 'Other')
AND e.pi_his_itm_app_trk_sts_name = 'Hired - External'
AND e.pi_his_itm_app_trk_step_name = 'Hire'
AND j.title NOT IN ('Student Ambassador Program for Eligible Summer Interns', 'Student Ambassador'))
WHERE rowrank = 1);

最佳答案

眼前的问题似乎是这部分:

...
AND J.TITLE IN (
SELECT * FROM (
SELECT DISTINCT J.TITLE FULL_TIME_DETAIL,
RANK () OVER (PARTITION BY E.PI_CANDIDATE_NUM ORDER BY E.PI_HIS_ITM_APP_TRK_CREATION_DT DESC) AS ROWRANK
FROM WC_HIRED_INTERNS_FA H
...

SELECT * 表示子查询返回两个列值,FULL_TIME_DETAILROWRANK。你实际上并不需要 ROWRANK ,所以将 * 更改为你想要的列:

...
AND J.TITLE IN (
SELECT FULL_TIME_DETAIL FROM (
SELECT DISTINCT J.TITLE FULL_TIME_DETAIL,
RANK () OVER (PARTITION BY E.PI_CANDIDATE_NUM ORDER BY E.PI_HIS_ITM_APP_TRK_CREATION_DT DESC) AS ROWRANK
FROM WC_HIRED_INTERNS_FA H
...

您正在执行大量子查询并重复大量代码,因此这可能会大大简化;也许研究分析功能。不过,这超出了这个问题和具体错误的范围。

关于sql - ORA-00913 : too many values in oracle subquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52082076/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com