Re: simple query question: return latest - Mailing list pgsql-general

From Scott Frankel
Subject Re: simple query question: return latest
Date
Msg-id DEA51CC8-34CC-11D9-B6EE-000A95A7B782@pacbell.net
Whole thread Raw
In response to Re: simple query question: return latest  (Michael Fuhr <mike@fuhr.org>)
List 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


pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: simple query question: return latest
Next
From: "Scott Chapman"
Date:
Subject: How to use custom functions created by my2pg.pl?