Re: BUG #8144: Problem with rank window function and CTEs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: marc(at)bloodnok(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8144: Problem with rank window function and CTEs
Date: 2013-05-10 03:28:50
Message-ID: 21696.1368156530@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

marc(at)bloodnok(dot)com writes:
> I have a query in which I want to use the result of a window function to
> isolate the most relevant results. While I was trying to develop and test
> the query, I discovered what looks like a bug in the results of the rank()
> function. This has been tried with the same results on 9.1.9 and 9.2.4

Well, you didn't provide enough information for somebody else to
reproduce the problem, but just looking at this I see no particular
reason to think there's a bug. In the first case, the
"where ao.org_id = 20150" clause filters rows before the rank() is
taken, whereas in the second case it filters after the rank() function.
I think the larger rank values indicate that there are other rows with
different org_id but the same item_id, which you won't see in the final
output in either case --- but in the second query, the rank() function
does see them.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Karsten Düsterloh 2013-05-10 08:34:02 Strange time zone +00:53:28
Previous Message Sergey Konoplev 2013-05-10 02:28:50 Re: Completely broken replica after PANIC: WAL contains references to invalid pages