Re: aggregate version of first_value function?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: aggregate version of first_value function?
Date: 2011-03-03 14:41:07
Message-ID: 6665.1299163267@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com> writes:
> We have window function version of first_value(),
> but aggregate version looks useful to write queries something like:

> =# CREATE TABLE obj (id integer, pos point);
> =# SELECT X.id,
> first_value(Y.id ORDER BY X.pos <-> Y.pos) AS neighbor
> FROM obj X, obj Y
> GROUP BY X.id;

> Is it reasonable? Or, do we have alternative ways for the same purpose?

I don't see any good reason to encourage people to write that in a
nonstandard way when there's a prefectly good standard way, ie,
use the window-function version.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message hom 2011-03-03 14:46:23 Open unmatch source file when step into parse_analyze() in Eclipse?
Previous Message Tom Lane 2011-03-03 14:38:39 Re: Quick Extensions Question