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

3312675Dec 4 2017 — edited Dec 5 2017

Greetings, I am running Oracle DB 12.1.0.2 on a Linux platform.

Kindly provide me suggestion on how I can rewrite the below query to get raid of duplicates in column, spbpers_ssn. This is what I have so far:

select spriden_id || ',' ||

spbpers_ssn || ',' ||

spriden_first_name || ',' ||

spriden_last_name || ',' ||

substr(spriden_mi,0,1)  || ',' ||

substr(SPBPERS_PREF_FIRST_NAME,0,10)

from spbpers, spriden, saradap

where spbpers_pidm = spriden_pidm

and spriden_pidm = saradap_pidm(+)

and spriden_change_ind is NULL

and ((spriden_activity_date > SYSDATE - to_yminterval('05-00'))

or (spbpers_activity_date > SYSDATE - to_yminterval('05-00'))

or (saradap_appl_date > SYSDATE - to_yminterval ('02-00')))

and spbpers_dead_ind is null

and spriden_entity_ind = 'P'

Order by spriden_last_name, spriden_first_name

I tried the below but it doesn't execute:

select distinct spriden_id || ',' ||

spbpers_ssn || ',' ||

spriden_first_name || ',' ||

spriden_last_name || ',' ||

substr(spriden_mi,0,1)  || ',' ||

substr(SPBPERS_PREF_FIRST_NAME,0,10)

from spbpers, spriden, saradap

where spbpers_pidm = spriden_pidm

and spriden_pidm = saradap_pidm(+)

and spriden_change_ind is NULL

and ((spriden_activity_date > SYSDATE - to_yminterval('05-00'))

or (spbpers_activity_date > SYSDATE - to_yminterval('05-00'))

or (saradap_appl_date > SYSDATE - to_yminterval ('02-00')))

and spbpers_dead_ind is null

and spriden_entity_ind = 'P'

Order by spriden_last_name, spriden_first_name

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 2 2018
Added on Dec 4 2017
4 comments
211 views