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 1nbUzb-00076j-42 for pgsql-sql@arkaria.postgresql.org; Mon, 04 Apr 2022 22:16:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbUzZ-00042u-Uc for pgsql-sql@arkaria.postgresql.org; Mon, 04 Apr 2022 22:16: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 1nbUzZ-00042l-L3 for pgsql-sql@lists.postgresql.org; Mon, 04 Apr 2022 22:16:09 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbUzW-0002Qs-UA for pgsql-sql@lists.postgresql.org; Mon, 04 Apr 2022 22:16:09 +0000 Received: by mail-pf1-x42b.google.com with SMTP id y10so10290756pfa.7 for ; Mon, 04 Apr 2022 15:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=b1xlWoYBzgpGMz+KeGamPgxPw/roAXc/0SVWC0WOv/c=; b=SiBIyqNt4nZP8oCSml0pVB5ZnkYn/YRyFeTNTuNNCG51uVRrV0tyEI00H80rukd76t kg15AaEGkNOQyPWm7HxaFU+qbeFEg1jkiHkll6p5xxdN6cIS6VkH5SrCNO+IXjEoIN4t XjfGnYz1LnFTtyu8mrleiOoDeqarEyGMO1oB2zz7eqdZvWM1kmjV8DZ330Q8golaTWpH 1dsTDLiqgRnjJWon6tmDQmMb4vt5HhNa8EnG34JcKjVoPxq9Brb5C+4k+//r+lKX32Qo KNhzrTJalj7ahOKfmt+iXCaVAs2d3YWRhKmU97e3qz5VsVsxR+/bSPTTHL1Tgl+lyNme Ey4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=b1xlWoYBzgpGMz+KeGamPgxPw/roAXc/0SVWC0WOv/c=; b=pw4Xc78/NRguumFtYIVV2aUT0SkL4Z2Jqq9CAf+LDADts8/P8UfcDoTfgnjTDNa/Ss swIhfD8ZVEepVSODr9zijXmVbs89gPKHjqgiHdbmAvx2B3XdHp+QkGpfaqrHBoqSpZbp yVHhUqhQcWkBqVb26Y78XmN0vC+fh6mZRUmgRyKl2mSiUJuW05qI0LYztu2XSF6tSNeu dVcakpYG0OltMR/i07FNeFIzYvg4042fbu027PLrsY4WqX/9C0NEa5FbDZANdRhFf9Wh PLof+2Yh5iu1W6Rsn1lARyl6Iqb3UpwjSefXtE6OYOBa6RKZQCqYrsB3hG5W82Ageksp EFdA== X-Gm-Message-State: AOAM531it2C0v4fYi4AmHWXayf7JapAmJidkP7Hh/0P8QpD29URIPcKN mDSxzjH6cy7MZjM22V6P6PzsYw1JNH4= X-Google-Smtp-Source: ABdhPJx0Dxwf1U6aKIL+0Ii5V6M1rZx27yiSSBshTgM0sQZrjc237wqbAEhQHFrBqblSTQJr6J0W5w== X-Received: by 2002:aa7:8d47:0:b0:4f6:a7f9:1ead with SMTP id s7-20020aa78d47000000b004f6a7f91eadmr221493pfe.42.1649110564237; Mon, 04 Apr 2022 15:16:04 -0700 (PDT) Received: from [10.128.71.194] ([155.98.131.2]) by smtp.gmail.com with ESMTPSA id c9-20020a056a00248900b004fb05c0f32bsm13847487pfv.185.2022.04.04.15.16.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Apr 2022 15:16:03 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------5DusNP97zOwYASAZm5JDDsDK" Message-ID: <3817c56b-458d-5295-e8bc-1001231dc5c8@gmail.com> Date: Mon, 4 Apr 2022 16:16:02 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: How to just get the last in a recursive query Content-Language: en-CA To: pgsql-sql@lists.postgresql.org References: From: Rob Sargent In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------5DusNP97zOwYASAZm5JDDsDK Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/4/22 16:14, Shaozhong SHI wrote: > > > ---------- Forwarded message --------- > From: *Shaozhong SHI* > Date: Mon, 4 Apr 2022 at 23:13 > Subject: How to just get the last in a recursive query > To: PostGIS Users Discussion > > > In this example, Network Walking in PostGIS · Paul Ramsey > (cleverelephant.ca) > > > 3 rows got returns as follows: > > |id --- 6 3 1| > || > |How to just get the last (namely, 1) in the most efficient way?| > Regards, David reverse the order of the last query and set limit 1 --------------5DusNP97zOwYASAZm5JDDsDK Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 4/4/22 16:14, Shaozhong SHI wrote:


---------- Forwarded message ---------
From: Shaozhong SHI <shishaozhong@gmail.com>
Date: Mon, 4 Apr 2022 at 23:13
Subject: How to just get the last in a recursive query
To: PostGIS Users Discussion <postgis-users@lists.osgeo.org>



3 rows got returns as follows:

 id
---
  6
  3
  1

How to just get the last (namely, 1) in the most efficient way?
Regards, David
reverse the order of the last query and set limit 1
--------------5DusNP97zOwYASAZm5JDDsDK--