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 1ofPub-0001on-IR for pgsql-novice@arkaria.postgresql.org; Mon, 03 Oct 2022 18:11:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ofPua-0007mw-4q for pgsql-novice@arkaria.postgresql.org; Mon, 03 Oct 2022 18:11:28 +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 1ofPuZ-0007mn-Lz for pgsql-novice@lists.postgresql.org; Mon, 03 Oct 2022 18:11:27 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ofPuS-0004fh-Pf for pgsql-novice@lists.postgresql.org; Mon, 03 Oct 2022 18:11:26 +0000 Received: by mail-ed1-x52a.google.com with SMTP id z97so15698927ede.8 for ; Mon, 03 Oct 2022 11:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date; bh=IRHyxEa+ZCzkT1EvaRk/52/CseyQrzVGZVRgQ/84FX4=; b=YuxXnlRAOv10kNuVBOKdmU/fI1unvKRdke0QW8U8qa1Av6945g3D3n66ErFkNJMJEa dZG8t/ysPOOqTprCpnF37SJnqgXS7CyMmLxW2FGUU2O/gnunj96ishZ50g5O8ZzljAp6 o7nToOKEsD68WMCCDWLBheBa14dYqiLNHmejc4MbGCqBDk03tjB5h9R6ky4wpfZnYF6L OCsic90BfhoTrgy8cVeQJukuRDvcWfCQVtw/4IHqQ6yXyzMvUNzYyRqlBQkz9gyozEiY kfclOKO8782qSQtU8Dv55u0vCqJtL5MdJ0Xx5fmzYqMCml7gRJkVcP2xZRhTK5Jp4Wmy R3Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date; bh=IRHyxEa+ZCzkT1EvaRk/52/CseyQrzVGZVRgQ/84FX4=; b=D9TCLk2eJAicNa7n+BBCJrnFjjk2S8bZ3Y072gvPnHGHx5e5K0OOnO37HLA8ZIXsT+ o+H7QV9BcdUu51T3aclFGUrTXDS0iAm9qbZEamIdAme/qHD0CLtXD35pmlNYRhCOeTaN /hTScLETFP/qbKxjy06tsmVZnut8B7F4c2ImnYaQf0qZq5dLryFjKbllq/997DVcDLj1 Cv0CPmjzC18oIz4HrzTBzXwtfiDRthHPoez56AnCvtW3+GYBwNc+9Arrdg9WMRu1ywos rOFxQVvzzH7BS9YC1CZVse0fDx7oZ4E3n7LT96EKoHch7RkBGfEXOv5wJrJ8EWyYqLLR Wutg== X-Gm-Message-State: ACrzQf3DOOe9HQILDmDX8V964jhuwYmYmFx4qXh9kb/uNn9S5hR3jO8m 14F27slyefxYaB+0BTjgRIKpjw== X-Google-Smtp-Source: AMsMyM4xM6BKRvJ1nP62z/BqOk/ljFXnjeF6+Sky/ArChT40Jj81nDZ3PqUzCe7qmdqL+zPHJV7E/w== X-Received: by 2002:a50:ed86:0:b0:458:e1da:af2 with SMTP id h6-20020a50ed86000000b00458e1da0af2mr7030364edr.364.1664820678557; Mon, 03 Oct 2022 11:11:18 -0700 (PDT) Received: from localhost.localdomain (178-190-175-21.adsl.highway.telekom.at. [178.190.175.21]) by smtp.gmail.com with ESMTPSA id dy10-20020a05640231ea00b00458d8c68241sm72629edb.18.2022.10.03.11.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 11:11:18 -0700 (PDT) Message-ID: Subject: Re: How can I create a feature request for QUALIFY clause into PostgreSQL? From: Laurenz Albe To: Onni Hakala , pgsql-novice@lists.postgresql.org Date: Mon, 03 Oct 2022 20:11:17 +0200 In-Reply-To: <6E722EEC-61FE-4EC0-B17D-B4468DA34BA1@keksi.io> References: <6E722EEC-61FE-4EC0-B17D-B4468DA34BA1@keksi.io> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2022-10-03 at 20:38 +0300, Onni Hakala wrote: > I was very happy learn about QUALIFY clause in BigQuery today. > > I have used window functions usually with subqueries like this: > SELECT * FROM ( >   SELECT >     *, >     ROW_NUMBER OVER (PARTITION BY something ORDER BY modified_date DESC) AS row_number >   FROM table_name > ) > WHERE row_number = 1 > > > With QUALIFY it's much more ergonomic and cleaner to do the same thing. > SELECT * > FROM table_name > QUALIFY ROW_NUMBER() OVER (PARTITION BY something ORDER BY modified_date DESC) = 1 > > > QUALIFY is also better since it doesn't include extra column row_number to the result. > > Where should I send message so that Postgres maintainers would consider adding this into the TODO page: https://wiki.postgresql.org/wiki/Todo PostgreSQL supports DISTICT ON, which can do this even more ergonomically. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com