Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1omygi-00007I-Jn for pgsql-sql@arkaria.postgresql.org; Mon, 24 Oct 2022 14:44:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1omygh-0008Go-49 for pgsql-sql@arkaria.postgresql.org; Mon, 24 Oct 2022 14:44:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1omygg-0008Gf-Px for pgsql-sql@lists.postgresql.org; Mon, 24 Oct 2022 14:44:22 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1omyga-0002sc-BS for pgsql-sql@lists.postgresql.org; Mon, 24 Oct 2022 14:44:21 +0000 Received: by mail-ed1-x532.google.com with SMTP id y69so13138259ede.5 for ; Mon, 24 Oct 2022 07:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=WivPGXPZI77vFOS4IQkC1Z9SSmxi5GbbigE4dFlkfyE=; b=OW9hyQ0kkkZBC2HgEQiSOg/7de5PZri51nfPGOKx53pK7yJ37cRlVBX9r6wc8xRo+J F0ZwNaW4UGdHIEJ4N0SSGfUWSzEaGSqoX84KbSGQZl00eyGHBnysQpeK7ih3M051m8c1 dOxaYfhAFCwv9sW0wvX94y/jpm5hzxQKZNOozQkIRdJ9KZTg657r7lkWRfz4DtQvh/oW b8xebaCUNdDDw2mWhgGHs69MukmXIRBTbN85uOH+0OsZ5hrXHqft866KO+JRvSMTbbdH jNZX/8RZbXrRmeGw3HKkF1JoiN/1OquKGDsl082m6IUbSG/Dwd0GE1Eu7X4F3MDAv1WR 4prg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WivPGXPZI77vFOS4IQkC1Z9SSmxi5GbbigE4dFlkfyE=; b=gDnF8kOMBXHBqGheaC7w5Db/K+FlIJ5ZmtviQQ1sF7624Rcm5TH6tT40QDv2sGgKPF TO1HX04KLzF+LcJhdq0t7h87th29FNgdpHeo6ydW7w//kTHSMU377oMcDwNMlAWWw72+ DQ3RHvjB9vEZWPYx4iyDFk2vnGNn/dP98RQyXStCUBDZ3l2yNBlAsC4OpQX4tohT0XSh OJLiNfIiUfEMuQe2TRXTZ/HtLBmLoD4UYKrJ0v34qyWmMoCsBm8Ri3jiWxg4FLKUMr5J Er+4STlL/PSOdBA74mMf1FEtdt8nIj7itRh3bdQdKQOQdWWSGGL6HVIQVEmQJ0W30liU lp2w== X-Gm-Message-State: ACrzQf2T9L8LfF9rf/KgMLETbDOWytRIEGxPuSoIJB2GvL2p/zfW8XHQ z0NMaLpfh2jLPS7I3ol8ctwcnXszjGuMKRKajHk9wTnG X-Google-Smtp-Source: AMsMyM7nU1LkQBp/posjLGbRzOPwLyFkwnNtzlvUWtk0ZfCoUG/J+k285+DTtkntMWdwdYYteU+EEffI94f+enSA0uQ= X-Received: by 2002:a17:907:3e01:b0:730:a690:a211 with SMTP id hp1-20020a1709073e0100b00730a690a211mr27662782ejc.596.1666622654871; Mon, 24 Oct 2022 07:44:14 -0700 (PDT) MIME-Version: 1.0 From: Shaozhong SHI Date: Mon, 24 Oct 2022 15:44:03 +0100 Message-ID: Subject: select only 1 pair To: pgsql-sql Content-Type: multipart/alternative; boundary="00000000000051820505ebc8d385" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000051820505ebc8d385 Content-Type: text/plain; charset="UTF-8" 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? Regards, David --00000000000051820505ebc8d385 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
There are pair ids.=C2=A0 Each pair is repeated.
<= br>
id1=C2=A0 =C2=A0id2
1=C2=A0 =C2=A0 =C2=A0 =C2=A02
2=C2=A0 =C2=A0 =C2=A0 =C2=A0 1
3=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A04
4=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A03

How to only select 1 unique pair for each?

Regards,

David
--00000000000051820505ebc8d385--