Reputation: 11
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.
Upvotes: 0
Views: 37
Reputation: 1312
select
ID,
FName,
LName
from your_table
union
select
PID,
PFName,
PLName
from your_table
order by 3, 2, 1
Upvotes: 0
Reputation: 1269773
You seem to have a symmetric relationship. So, you can do:
select t.*
from t
where t.id < t.pid;
Upvotes: 1