Re: BUG #8144: Problem with rank window function and CTEs - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #8144: Problem with rank window function and CTEs
Date
Msg-id 21696.1368156530@sss.pgh.pa.us
Whole thread Raw
In response to BUG #8144: Problem with rank window function and CTEs  (marc@bloodnok.com)
List pgsql-bugs
marc@bloodnok.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

pgsql-bugs by date:

Previous
From: Sergey Konoplev
Date:
Subject: Re: Completely broken replica after PANIC: WAL contains references to invalid pages
Next
From: Karsten Düsterloh
Date:
Subject: Strange time zone +00:53:28