Reputation: 38213
SELECT * FROM MyTable
a | b
---+----
1 | 2
2 | 10
2 | 5
3 | 10
I want each number to only appear once in each column, i.e. the result should be:
a | b
---+----
1 | 2
2 | 10
Is this possible?
Upvotes: 0
Views: 78
Reputation: 450
I suggest to add a column with ID. Then do this:
select a, b from mytable m1 where
a not in (select m2.a from mytable m2 where m2.id < m1.id)
and
b not in (select m3.b from mytable m3 where m3.id < m1.id)
If you don't want to decide by the order of IDs, you can add another column (like a sequence).
Upvotes: 1