Re: [QUESTION] Window function with partition by and order by

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ankit Kumar Pandey <itsankitkp(at)gmail(dot)com>
Cc: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: [QUESTION] Window function with partition by and order by
Date: 2022-11-27 16:28:04
Message-ID: 355604.1669566484@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ankit Kumar Pandey <itsankitkp(at)gmail(dot)com> 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://stream.boxwatch.ru/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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ankit Kumar Pandey 2022-11-27 16:54:51 Re: [QUESTION] Window function with partition by and order by
Previous Message Samed YILDIRIM 2022-11-27 16:23:38 Re: [QUESTION] Window function with partition by and order by