pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: marc@bloodnok.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8144: Problem with rank window function and CTEs
Date: Thu, 09 May 2013 23:28:50 -0400
Message-ID: <21696.1368156530@sss.pgh.pa.us> (raw)
In-Reply-To: <E1UactF-0000HI-2C@wrigleys.postgresql.org>
References: <E1UactF-0000HI-2C@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


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



view thread (2+ messages)

Message-ID: <21696.1368156530@sss.pgh.pa.us>
Permalink:  ../21696.1368156530@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21696.1368156530@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, marc@bloodnok.com
  Subject: Re: BUG #8144: Problem with rank window function and CTEs
  In-Reply-To: <21696.1368156530@sss.pgh.pa.us>
  References: <E1UactF-0000HI-2C@wrigleys.postgresql.org> <21696.1368156530@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox