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 1qHRCL-0006B0-8D for pgsql-sql@arkaria.postgresql.org; Thu, 06 Jul 2023 15:47:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qHRCK-0007el-5t for pgsql-sql@arkaria.postgresql.org; Thu, 06 Jul 2023 15:47:12 +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 1qHRCJ-0007eR-Tg for pgsql-sql@lists.postgresql.org; Thu, 06 Jul 2023 15:47:11 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qHRCG-002NdY-Ft for pgsql-sql@lists.postgresql.org; Thu, 06 Jul 2023 15:47:10 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-98dfb3f9af6so111084566b.2 for ; Thu, 06 Jul 2023 08:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688658427; x=1691250427; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=rrbaojZyEKFPs8BMlRW+ZmJiPHhZh2pybAUuCCFjmDk=; b=V4a8Rd3JquVjZqyz5bf+/0sKkuf5B1VYyKVn1SVlqexTpvwpqSAR1PSCK1TPH0Tf0o zFOyYhZy7SbCwHXZSa2kIR3pBrz0hRMAkPJ0rWN6+wXUALcjxBrr+UI9a1JlQ6aIW4iO CG8XISuqmnE2ZN37oI4jhTuzESFw9bw2vHrp4E0tceuo/wQFrXotN4DCT5eNWkuaTpLG ndM7zmosXHPuDiaPNLpONMY260t9Ya0Ewul1PoSlf8fmhihaC24LBu2VdX3Y0zvBvXB5 8gZqFuJa0i4jBMan4etMOvv1ByQC2WPusRXsYPGEOnoI65Hn6lPJrv7M30of6e8SCNGs JsQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688658427; x=1691250427; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rrbaojZyEKFPs8BMlRW+ZmJiPHhZh2pybAUuCCFjmDk=; b=C4Vre9YYpO9yZfmZKpo+toMPvZvdVTQ6XsJbWAgFcrIRe8Dzma3zUvMdFY1v+G85Db L0Vx0nd2qRWoi+6sFlOodPUrMq4tjVlL8z/SH8uCR1guC+HDw2YNkx46uztVV6ye5+cP oKnzCJ2N6WNhcvvWJq2l0FXoMYc71cNnQGXd+ISbTbgPDlig9ECPI0lhrPr0CkfxqgAK Z9qYJfXfU76JHijD68rSwhT+9BEQdaFXtYkxX0ujiYY/enyMlT51Ohpt/l3WdHy+WX4j B3+t9EGc25I3PhDbXmX506awdmm8/ZrHznyXneDH10lZh5wNqvdLGy1kKED2RdoyweQk RTBA== X-Gm-Message-State: ABy/qLbNFaYSNgXPS97qzJnSFjoeQKHUuYeoeKBGua5JGW45GlGAocOL liD90Xm7o6TPUs0Xp+a86Tem6zuao+Zp9cRx0OS5SaB7 X-Google-Smtp-Source: APBJJlEGX3ir2tJ5QEYW9AySODmUz2DoNn3UXWX7s2rhcNY5a5PQBO+Z4nNYu0Vcpj63b2iX6FWMbZvjp/ETiBxi2jI= X-Received: by 2002:a17:906:10cf:b0:974:5e14:29c0 with SMTP id v15-20020a17090610cf00b009745e1429c0mr1944778ejv.21.1688658426802; Thu, 06 Jul 2023 08:47:06 -0700 (PDT) MIME-Version: 1.0 From: Shaozhong SHI Date: Thu, 6 Jul 2023 16:46:55 +0100 Message-ID: Subject: How to select the last value/row? To: pgsql-sql Content-Type: multipart/alternative; boundary="000000000000ad358d05ffd36dd0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ad358d05ffd36dd0 Content-Type: text/plain; charset="UTF-8" Given, ID 5 4 3 3 2 1 How to select the last one, to end up with 1 In Python, there are ways to handle ordered list. In Postgres, is there something similar? Regards, David --000000000000ad358d05ffd36dd0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Given,
ID
5
4
3
3
2
1


How to = select the last one, to end up with

1
In Python, there are ways to handle ordered list.
In Postgres, is there something similar?

<= div>
Regards,

David
--000000000000ad358d05ffd36dd0--