Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Select Distinct Query Left JOIN, Still getting duplicates in my result

User_H76VHAug 5 2016 — edited Aug 8 2016

I am writing a select query with distinct but I am still getting duplicates in my result. The Oracle View do have duplicates and I am trying to get back only 1 occurrence of that value.

Here is my query

select

  person.person_id,

  person.last_name,

  person.first_name,

  person.first_name,

  person.middle_name,

  skill.skills_id,

  (case

     when trim(skills.skill_description) = 'typing fast' then 'TP1'

     when trim(skills.skill_description) = 'courier district 9' then 'CD9'

     when trim(skills.skill_description) = 'helpdesk shift 3' then 'HD3'

     when trim(skills.skill_description) = 'helpdesk shift 5' then 'HD5'

     ....

     else ''

  end) AS skill_description

from person_view person

left join (select distinct person_id, skill_id, skill_description, updated_date

             from skill_view) skills

on skills.person_id = person.person_id and

trim(skills.skill_description) in ('skill1', 'skill2', 'skill3' ...)

There is a lot of values for skill_description, so I add the IN clause to filter for 15 - 20 specific skill_description values.

My case will take a the value and set the code for it.

I thought when I used the 'distinct' keyword it would filter out the duplicates but it is not working.

Here is my output so far

105    John E Doe     SKILL1

105    John E Doe     SKILL1

105    John E Doe     SKILL2

105    John E Doe     SKILL2

105    John E Doe     SKILL3

105    John E Doe     SKILL3

Any help is appreciated. Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 5 2016
Added on Aug 5 2016
7 comments
10,033 views