On Mar 25, 2008, at 11:33 AM, Sam Mason wrote:
> On Mon, Mar 24, 2008 at 05:27:04PM -0500, Decibel! wrote:
>> On Mar 20, 2008, at 2:23 PM, Sam Mason wrote:
>>> SELECT i, (MIN((j,k))).k
>>> FROM tbl
>>> GROUP BY i;
>> How is that any better than SELECT i, min(k) FROM tbl GROUP BY i ?
> Because I want the value of k associated with the minimum value of j.
Ahh, makes sense. FWIW...
SELECT i, (SELECT k FROM ... WHERE i = i.i ORDER BY j LIMIT 1)
FROM (SELECT DISTINCT i FROM ...) i
If you needed more than just k, I think there's a way to do that in
the FROM clause, too.
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828
In response to
pgsql-hackers by date
|Next:||From: Marc G. Fournier||Date: 2008-04-02 23:18:03|
|Subject: Re: Several tags around PostgreSQL 7.1 broken |
|Previous:||From: Tom Lane||Date: 2008-04-02 23:04:09|
|Subject: Re: [GENERAL] ANALYZE getting dead tuple count hopelessly wrong |