--All candidates that match every skill in a position
select distinct candidateID, positionID
from
(
--Match candidates and positions, count number of skills that match
select candidateID, positionID, skills_per_position
,count(*) over (partition by candidateID, positionID) matched_skills
from candidateSkills
inner join
(
--Number of skills per position
select positionID, skillID
,count(*) over (partition by positionID) skills_per_position
from positionSkills
where status = 'Open'
) positionSkills_with_count
on candidateSkills.skillID = positionSkills_with_count.skillID
where available = 'True'
)
where matched_skills = skills_per_position
order by candidateID, positionID;
그러나
create table candidateSkills as
select 1 candidateid, 2 skillID, 'True' available from dual union all
select 1 candidateid, 3 skillID, 'True' available from dual union all
select 2 candidateid, 1 skillID, 'True' available from dual union all
select 3 candidateid, 1 skillID, 'True' available from dual union all
select 3 candidateid, 3 skillID, 'True' available from dual;
create table positionSkills as
select 1 positionID, 1 skillID, 'Open' status from dual union all
select 1 positionID, 3 skillID, 'Open' status from dual union all
select 2 positionID, 1 skillID, 'Open' status from dual union all
select 3 positionID, 2 skillID, 'Open' status from dual union all
select 3 positionID, 3 skillID, 'Open' status from dual;
을 내 결과가 약간 있습니다 다른. 후보자 3은 2와 3이 아닌 1과 2의 위치와 일치합니다.이 단어가 귀하의 예에서 오타이기를 바랍니다.
또한 내 출력을 내 것과 정확하게 포맷하지 않았습니다. SQL을 여러 줄 형식으로 결과를 표시하는 것은 약간 까다로울 수 있습니다. 그러나 SQL을 포맷되지 않은 채로두면 다른 프로세스에서 사용하려는 경우 더 유용합니다.
도움 주셔서 감사합니다. 쿼리는 어떤 후보와도 일치하는 후보를 출력합니다 ..skilll 그러나 원본 게시물의 출력에 표시된대로 후보가 특정 위치의 모든 스킬을 충족시키는 지 확인해야합니다. – amitl
오케이, 이제 수정했습니다. 나는 이것이 당신을 위해 일할 것이라고 믿습니다. – moleboy
대단히 감사합니다. 제 문제를 완벽하게 해결했습니다. 필자는 원래의 pl/sql 함수에이 코드를 사용하여 원하는 출력을 제공 할 수있었습니다. – amitl