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 1ozKvj-0004zW-2E for pgsql-sql@arkaria.postgresql.org; Sun, 27 Nov 2022 16:54:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ozKvh-0004wE-Rs for pgsql-sql@arkaria.postgresql.org; Sun, 27 Nov 2022 16:54:57 +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 1ozKvh-0004w5-HZ for pgsql-sql@lists.postgresql.org; Sun, 27 Nov 2022 16:54:57 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ozKvf-0005Pb-8o for pgsql-sql@lists.postgresql.org; Sun, 27 Nov 2022 16:54:56 +0000 Received: by mail-pl1-x632.google.com with SMTP id j12so8081754plj.5 for ; Sun, 27 Nov 2022 08:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=5FNZ1zCA395bsqotF2m1tGaQ+YEeuJA8vKp5QY7rJ+w=; b=iRQDtdtfBboYVwto9asSb/WifvjpfWg89i5QXfih+a7Mdr854sIxCptgTGuNZJwFTN SDHMGiDbLMf/VxW2MgBbDDpvmFpofi6yeAxlwm2AH/FH+xwzvLmmtpW8SD1xWMKZrnLM ++Oj433E+gHcmtHVEkQ37Xu2uV3KjUWIzzb102SN/qNvHmb+Vw/8d1j8P5h0UfE9npUU rXLZvEcu2kfPNXhyWDNzxNY0909yIXSFUtgVqIdhQyqVU8iW3KJr2j3Vr3ig+J9Pej2V a3zRd1CwRWWYCJAVVzxlTiHndfnTqgYuFBdUAsGzNb4NRIAfNQocUA73f89Nf80nbFiU D/jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5FNZ1zCA395bsqotF2m1tGaQ+YEeuJA8vKp5QY7rJ+w=; b=rKymudNSAsWdYQ5jvbNkReZ/0bA+DlwDRzaO0OOZz18yjazE3ltA5H6Jz4yUHOXh11 Bwb6w/b/7PiEvtitq7pUjssPGBYGWS+5Wp+IEzg5ZphnIh+3Eha/Ae0IZtLFhYEm1YD1 ciM0yyrWRU7WesISpU/YnrfO9XfimwuHPJFXAE8jdIph+jlQyFG8ob27wVgnMqS9czzH LoThqd7WQIcPHr53OqVL5UblHLyLqkx8oknGwg5lVY4hQM+7+lNBOS+KXMwGQA1HsI0J GQAWRA7AQNpuOYxtB8ITCtosJlsgBRX7ORjd0tlExp6skmrcUv7E7qzI8LJxnBiouOBR fB4Q== X-Gm-Message-State: ANoB5pnDNrZfOxYz+s2xUHnAtatQMr5+f4Y4Vz6o+lsb3dmW+szt6qgZ 9XQOUYiV4IKBPiKsFh8eoFznpqG26to= X-Google-Smtp-Source: AA0mqf5SQZEGktADDmBm3ofWn2WqlbhsvrngOIzfT/6FuVZIfwHJXPjpwdzdCxZHcfXY+rpgyAXMbA== X-Received: by 2002:a17:902:6904:b0:188:fd9b:479d with SMTP id j4-20020a170902690400b00188fd9b479dmr31262545plk.93.1669568094229; Sun, 27 Nov 2022 08:54:54 -0800 (PST) Received: from [10.0.2.15] ([122.163.232.215]) by smtp.gmail.com with ESMTPSA id m127-20020a625885000000b0056bc5ad4862sm6386936pfb.28.2022.11.27.08.54.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Nov 2022 08:54:53 -0800 (PST) Message-ID: Date: Sun, 27 Nov 2022 22:24:51 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [QUESTION] Window function with partition by and order by Content-Language: en-US To: Tom Lane Cc: pgsql-sql@lists.postgresql.org References: <7f9f9b1d-b612-d0bd-4674-cfb5a8b2d343@gmail.com> <355604.1669566484@sss.pgh.pa.us> From: Ankit Kumar Pandey In-Reply-To: <355604.1669566484@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 27/11/22 21:58, Tom Lane wrote: > Ankit Kumar Pandey writes: >> Question is: Average of id for partition name (A) should be 6/4 = 1.5 >> for all rows in that partition but this result is seen only at the last >> one row in partition (A). Am I missing here something? > https://www.postgresql.org/docs/current/tutorial-window.html > > particularly: > > By default, if ORDER BY is supplied then the frame consists of all > rows from the start of the partition up through the current row, plus > any following rows that are equal to the current row according to the > ORDER BY clause. > > regards, tom lane Thanks, I understand the behavior now. -- Regards, Ankit Kumar Pandey