Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvfHm-006Tdw-8h for pgsql-novice@arkaria.postgresql.org; Wed, 25 Oct 2023 14:55:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qvfHk-004hpe-4G for pgsql-novice@arkaria.postgresql.org; Wed, 25 Oct 2023 14:55:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvfHj-004hpM-Rf for pgsql-novice@lists.postgresql.org; Wed, 25 Oct 2023 14:55:03 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qvfHg-002fBV-Ul for pgsql-novice@lists.postgresql.org; Wed, 25 Oct 2023 14:55:03 +0000 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3b2f2b9a176so3841904b6e.0 for ; Wed, 25 Oct 2023 07:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698245699; x=1698850499; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pGh7Z7VzkwvMx0g1TuFblcP9vWAAd60tQts3v3xqEo8=; b=lTHjb1OMbHcnk9kzwYae3ncssPGmfCYMjDVV/XOCpyzWtN5Zxd6+Z1GYlPhsC6VoLA uqWmwg8LRfpkLIykeR3gdPF83imxThpiBuUN0cInjyT+Rjxw90DVkpmihmoYO42iTZae hT63OEnLAeMbx9c/ohXQ9Cy7c3bh/6cTWl7EYNwpMHWgieJTR7TnzP/ee9GiLVjYCDTs WoX1fi9nxsnjXg5Doq39/ITTQP6deZFnLwrHq2Tzw+AZ6lqD7MxW7/ijdItvm4bEdDnw IEnp73+RmcEJJD+IX2gCmyFpMuybW09G05/vGFZceUDUyi/O/0TCiLGLHVJ5XS/MNx+D qDjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698245699; x=1698850499; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pGh7Z7VzkwvMx0g1TuFblcP9vWAAd60tQts3v3xqEo8=; b=NHx4LpBkFZouPupsmG0VbF4IPj9SAerD+97hv/B8Nc6/+6R49+b3tqGZt0BDA4Qi2n NTExwZXNh/TZqsHACxSHU4V1pJF84rjOhdC3mm7PrW701kKCtkwF0I+04CdbzJjuDIUP 08SAalmfdSnc74fNYFGEcHQJECNXIAa/J6W2Px0H/LvnmLwr/5fflFq8xwNjIHJ/j7ZH xhjzNZyRL+iHKxGGay+OKYPO3wV/0dqSiZakGP1Ral5TkNS8VtFOPJYbBWllCBgYBsnQ MvDv9/XPixSb+873Kf0yT4AtsvGuO19u1OyiCioEAL+eZtBFUUBUvmBFrsPs/c9Mn+u8 NbJA== X-Gm-Message-State: AOJu0Yyx1dl8XAs4e9yQfNL+LlvY7vwVrzfJAAIwu+tnurjjscNBXZ2r u+OQhXUm45WRMBglBz77j7I+s7oIZBfiqnAg2vM= X-Google-Smtp-Source: AGHT+IHk1NILTF7jkQmVrQp6vzQ7GxbVW7KPOWg5x+Stz0hTz5ssLKxS0DUJeC/gUJ+AX9bZgeqONp/cvTMMoeu2jT0= X-Received: by 2002:a05:6808:2391:b0:3ab:84f0:b490 with SMTP id bp17-20020a056808239100b003ab84f0b490mr18361837oib.27.1698245699267; Wed, 25 Oct 2023 07:54:59 -0700 (PDT) MIME-Version: 1.0 References: <1901532185.8873313.1696511707263@mail.yahoo.com> <1653003450.12126241.1697462972371@mail.yahoo.com> In-Reply-To: From: "David G. Johnston" Date: Wed, 25 Oct 2023 07:54:42 -0700 Message-ID: Subject: Re: Reporting by family tree To: Ibrahim Shaame Cc: swastik Gurung , "pgsql-novice@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000a56fa906088ba342" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a56fa906088ba342 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Oct 25, 2023 at 5:21=E2=80=AFAM Ibrahim Shaame = wrote: > But what I want to get is grandfather - father - children: > > 1 - Grandfather1 > > 3 - father1-1 > > 6 - son1-1 > > 7 =E2=80=93 son1-2 > > 4 - Father1-2 > > 8 - son2-1 > > 2 =E2=80=93 Grandfather2 > > 5 - Father2-1 > > etc > > > Any suggestion > > If you want a different ordering of the output change the ORDER BY specification. Specifically, you want to order by the path of each person. Since that can only be determined during the traversal you need to create the path data yourself. I suggest using an integer[] (integer array) to store the path using ID values as breadcrumbs. David J. --000000000000a56fa906088ba342 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Oct 25, 2023 at 5:21=E2=80=AFAM Ibrahim Shaame <= ;ishaame@gmail.com> wrote:
But what I want to ge= t is=C2=A0 grandfather - father - children:

=09 =09 =09

1 - Grandfather1

3 - = father1-1

6 - = son1-1

7 = =E2=80=93 son1-2

4 - = Father1-2

8 - = son2-1

2 = =E2=80=93 Grandfather2

5 - = Father2-1=20

etc<= /p>


Any suggestion


If you want a different ordering of the output change the ORDER BY specifi= cation.

Specifically, you want to order by the path of= each person.=C2=A0 Since that can only be determined during the traversal = you need to create the path data yourself.=C2=A0 I suggest using an integer= [] (integer array) to store the path using ID values as breadcrumbs.
<= div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif= ">
David J.

--000000000000a56fa906088ba342--