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 1nzIMU-0001hl-5u for pgsql-general@arkaria.postgresql.org; Thu, 09 Jun 2022 13:38:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nzIMT-0005G6-2k for pgsql-general@arkaria.postgresql.org; Thu, 09 Jun 2022 13:38:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nzIMS-0005Fw-OB for pgsql-general@lists.postgresql.org; Thu, 09 Jun 2022 13:38:08 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nzIMQ-0001JV-Eo for pgsql-general@postgresql.org; Thu, 09 Jun 2022 13:38:08 +0000 Received: by mail-ej1-x632.google.com with SMTP id kq6so34503186ejb.11 for ; Thu, 09 Jun 2022 06:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=zD8D2wB6DP8I7Q3JsCqMPGFrVhQKOqH1EnG2YdmxMik=; b=nc7cEgkIgstFFMwyHt5ZSSepXogJ0/bIr95v3vhZ/O/6xdmPCv2/Kj6pAUIidougF0 hjl/7Qigb0Xvpwxl36W7wPtfGquME6qTkf9JZ0kaJ9bZQ3ZLpS+FJ8ngLueHshOPzzY4 43OcVCJWyQFF1+zJ3UyiZJ4OdXnm/xsT876zmbJv1Ns93M8EfKaFaECxws2/dBC7R2pA WokhmeWraZbz/AXdZB6+cADuhmUpPoRN9ACkQDi6E6n+YN8ndBj8d8Kq34u+yX9GHEuz vQxytkkrUBAgkVqYUuYF1N5KlDS8z6mW6Nelo3lwCcCOXE7UqZWayW/1HRb+oBdT5Vxv pyBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=zD8D2wB6DP8I7Q3JsCqMPGFrVhQKOqH1EnG2YdmxMik=; b=FrNBdAB9c+rC/ClT3xZSOdTC9ErBhE7ruwZWi7T75SmlnjeY3Kq8n/bp0UjBl4zbbS IjzLcAA6hGkFrAJIo7n40D2UQtG22M3p6t1l3ZxYzaLHvqnfC0OuMhPSLkoVNhoxQfs3 q5ldx+9zVCnkMrF26QpHcsQU/SRSJBWQ2lLTE3sXxUA1NlbmB8ushgsYcq3b0LRYTjur net0uKlTYiGWhtTU8jO+3A9ZIEbc/UCAatJ/t8+uU7ewtm+BfOT9fp6zFe7oQ8KTpyks Fcxy14c+8lD6aBaQ+VxxfRfZ0LNpfclByj3uQ/iW9CvxnEn8mRTfPr7CqnAug4YcleKt Nc2w== X-Gm-Message-State: AOAM531zRtKP2+draFIX8xvcovIGjv1qJTMFg8KxOZ0KfgxkFNxOkHG7 5mW1MqdlFqs/23jg6LrvwBc/tgvIeDkSaD2GMHCw9Dvc X-Google-Smtp-Source: ABdhPJwBOHd8vONZPaxapR+qo1FXQL/NJVWPJDY7AuSorR+O94QMoZ+70GkLS6AnaPhNqE5whYZR4cVnggKgARMS4C8= X-Received: by 2002:a17:906:2dcb:b0:711:d53f:e780 with SMTP id h11-20020a1709062dcb00b00711d53fe780mr17130081eji.325.1654781885478; Thu, 09 Jun 2022 06:38:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shaozhong SHI Date: Thu, 9 Jun 2022 14:37:54 +0100 Message-ID: Subject: A function to find errors in groups in a table To: Pgsql-general Content-Type: multipart/alternative; boundary="00000000000076fefb05e103ee28" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000076fefb05e103ee28 Content-Type: text/plain; charset="UTF-8" There is a table full of grouped values like the following nodeid link_type primary 11 outflowlink 1 11 inflowlink 1 11 outflowlink 2 Primary of 1 indicates a primary water course. Primary of 2 indicates a secondary water course. Obviously, one of the out flow links is an error, as its primacy value is 2. It is wrong that water flows from a primary water course into a secondary water course. How can a function can be designed to find and report such errors? Regards, David --00000000000076fefb05e103ee28 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
There is a table full of grouped values like the following
=

nodeid=C2=A0 =C2=A0 =C2=A0link_type=C2=A0 =C2=A0 =C2= =A0 primary
11=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0outfl= owlink=C2=A0 =C2=A0 =C2=A0 =C2=A01
11=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 inflowlink=C2=A0 =C2=A0 =C2=A0 1
11=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 outflowlink=C2=A0 =C2=A0 =C2=A02<= /div>

Primary of 1 indicates a primary water cours= e.=C2=A0 Primary of 2 indicates a secondary water course.

Obviously, one of the out flow links is an error, as its primacy va= lue is 2.=C2=A0 It is wrong that water flows from a primary water course in= to a secondary water course.

How can a function ca= n be designed to find and report such errors?

Rega= rds,

David
--00000000000076fefb05e103ee28--