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 1nzIM3-0001gY-OY for pgsql-sql@arkaria.postgresql.org; Thu, 09 Jun 2022 13:37:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nzIM2-0003E4-1S for pgsql-sql@arkaria.postgresql.org; Thu, 09 Jun 2022 13:37:42 +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 1nzIM1-0003Du-OU for pgsql-sql@lists.postgresql.org; Thu, 09 Jun 2022 13:37:41 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nzILz-0007w4-FU for pgsql-sql@lists.postgresql.org; Thu, 09 Jun 2022 13:37:40 +0000 Received: by mail-ej1-x630.google.com with SMTP id gl15so33671364ejb.4 for ; Thu, 09 Jun 2022 06:37:39 -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=VLxbIOhuKMbHSQV+0SCO5Vdze62WybeeV6LozEF7+JQ=; b=P3Cdl4OVbHFNo/V3Fvdb6DUmJjehQhuPtou94wDhsP/ZJheOjVRgBvepFB2K8D9mmX p8ybravCvOwHD2hnMECVbMOdGzWMehbFm/hOCWyRqGvTUOqE/ldk9odtVS/QGSNcYo1s hS7yqe8wCl9+i/rfU+y+k/iTRqOD0MZHiMJN6hMqOmx3KWfdl3pOtNwEj2AV0A9Rh2tP aiVi0lh4CqzYRzhnJtgikz0o1xVJt142JFpu5HzT8VGwXBwD/3gVHz4qxFMCDYWnu4BU JQYdxm2Le+5ZlQnSMlOmMpOzgjcxH9tsNixJahW7AH/BDZt0gW/aRFc5Osqy+DMOnz91 FBpA== 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=VLxbIOhuKMbHSQV+0SCO5Vdze62WybeeV6LozEF7+JQ=; b=LrtSER0dS56LCMR5B0jg4dU3u0qK/lHCcBWgQnkjWTTNKbVG9ZBXXZJLsnXPYE0Uoz EP1ftoi/Vgz3FeslNn15tr3F60CiM7yu+kvyyTcwMIga44ISjb8lBuJTtnt5JHm5lL/6 z0fik4J01/3+yph32bPPUvKTbauKPFPnQsX5t6xA0T6izwOy5h7rxTBxViXYZG2++dpu l+pTPie8nl6TZYrGJNJF7oamvf2aRwSo3LZbh5e0/EhbERXdn1FXVyMTOzc5kxfkxXp6 dsfVkKBenEmfKT6Zbw7K9GsTkQFBgMnQv7fUN2zo1nWIqU5GNUjS5/PTWFYnLJJ1YOzE c2kA== X-Gm-Message-State: AOAM531dwlI+W+cteJ6gdjVcgRezmfLZgZICbM3G19N7S6Cr/Ycl6/+G 2WJOrG6I8LknEZE1ieZ9RrLs+NZdHTBZtwhs0ZpM7U0t X-Google-Smtp-Source: ABdhPJx8cbqQJa61fO29Z9ZNC6Cp6MHB9W+W80RNulH7F4DQ+u1VhcAsa14vhTi80RePpgJfP+nrMB/ZNqO5Ad75KN8= X-Received: by 2002:a17:906:ae92:b0:711:2b64:c829 with SMTP id md18-20020a170906ae9200b007112b64c829mr24872738ejb.89.1654781858191; Thu, 09 Jun 2022 06:37:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shaozhong SHI Date: Thu, 9 Jun 2022 14:37:27 +0100 Message-ID: Subject: A function to find errors in groups in a table To: pgsql-sql Content-Type: multipart/alternative; boundary="000000000000d69b0005e103ec93" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d69b0005e103ec93 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 --000000000000d69b0005e103ec93 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=A0outflowlink=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 o= utflowlink=C2=A0 =C2=A0 =C2=A02

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

Obviously, one of the out flow link= s is an error, as its primacy value is 2.=C2=A0 It is wrong that water flow= s from a primary water course into a secondary water course.

=
How can a function can be designed to find and report such error= s?

Regards,

David
--000000000000d69b0005e103ec93--