claghorn
claghorn

Reputation: 11

Oracle SQL to get Unique Records

Does anyone know the sql to pull 4 rows from the following table which contains 8 rows? Just want one row for each arbitrary person. The real data will be thousands of records so it must be generic and use only the ID's not the names.

table

Upvotes: 0

Views: 37

Answers (2)

McMurphy
McMurphy

Reputation: 1312

select
    ID, 
    FName,
    LName
  from your_table
union
select
    PID,
    PFName,
    PLName
  from your_table
order by 3, 2, 1

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269773

You seem to have a symmetric relationship. So, you can do:

select t.*
from t
where t.id < t.pid;

Upvotes: 1

Related Questions