sql - Filter rows that have the same data in different columns -


this question has answer here:

i have data looks this:

 | b 97 |556 257|803 803|257 257|323 556|97 

i'm trying figure out best way filter results such removes duplicate rows. example shows row 257|803 , not 803|257. best way this?

select * t x x.a < x.b or not exists (    select *    t y     y.a = x.b , y.b = x.a    ); 

the truth table strange condition:

 | b  | (a<b) | (not exists) | (a<b or not exists) ---+----+-------+--------------+---------------------- 97 |556 | true  | false        |  true 257|803 | true  | false        |  true 803|257 | false | false        |  false 257|323 | true  | true         |  true 556|97  | false | false        |  false 

result:

   |  b   -----+-----   97 | 556  257 | 803  257 | 323 (3 rows) 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -