Re: simple query question: return latest

From: Scott Frankel <leknarf(at)pacbell(dot)net>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Goutam Paruchuri <gparuchuri(at)oneil(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: simple query question: return latest
Date: 2004-11-12 17:04:09
Message-ID: DEA51CC8-34CC-11D9-B6EE-000A95A7B782@pacbell.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Nov 12, 2004, at 8:24 AM, Michael Fuhr wrote:

> [Top-posting fixed]
>
> On Fri, Nov 12, 2004 at 09:06:08AM -0500, Goutam Paruchuri wrote:
>
>> Scott Frankel wrote:
>>
>>> ORDER BY DESC LIMIT 1 is much simpler and more readable than a
>>> sub-query. Though the sub-query approach looks to be a good template
>>> for ensuring more accurate results by being more explicit.
>
> Scott, how would a subquery "ensure more accurate results by being
> more explicit"?
>

Good question. I'm just now starting to construct sub-queries.
Perhaps naively,
I assumed that setting g.date explicitly equal to the results of a MAX
function
would return more reliable results than limiting a return list to just
the first value
listed. Though it's entirely possible that both approaches use the
same logic
under the hood.

Nonetheless, I'm using the DESC LIMIT 1 approach for now as it yields
the
results I need and is much more readable.

Thanks again!
Scott

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Chapman 2004-11-12 17:07:36 How to use custom functions created by my2pg.pl?
Previous Message Michael Fuhr 2004-11-12 16:24:07 Re: simple query question: return latest