Re: select only 1 pair

shammat@gmx.net

From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-sql@lists.postgresql.org
Date: 2022-10-24T15:08:52Z
Lists: pgsql-sql
Shaozhong SHI schrieb am 24.10.2022 um 16:44:
> There are pair ids.  Each pair is repeated.
>
> id1   id2
> 1       2
> 2        1
> 3         4
> 4         3
>
> How to only select 1 unique pair for each?

select distinct least(id1,id2), greatest(id1,id2)
from the_table