Rank()over(Oracle分区返回1条记录

时间:2018-08-29 12:45:34

标签: sql oracle oracle11g

我需要提取每个候选人的职位,因为在某些情况下可以聘用候选人,然后取消聘用,所以我使用排名功能来确保我只选择最后一个我们雇用了某人的工作。问题是当我确定我有多个记录时,我的查询仅返回一个记录。这是我正在使用的oracle代码。

SELECT E.PI_CANDIDATE_NUM,
       J.TITLE,
       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
 WHERE     ROWNUM = 1
       AND J.JOB_FAMILY_NAME IN ('M', 'P', 'E', 'O')
       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');

1 个答案:

答案 0 :(得分:4)

您似乎需要:

INPUT