On 24/02/10 22:47, Dave Crooke wrote:
> I'd imagine it would be possible to have a query planner optimization
> that would convert Garrett's DISTINCT ON syntax to do what I was
> trying to, by realizing that DISTINCT ON X ... ORDER BY Y DESC is
> going to return the the one row for each X which has the highest value
> of Y, and so use a MAX-structured accumulation instead of a sort.
Why is there only one row? For city temperatures, that seems unlikely.
In the event of more than one row does your algorithm give repeatable
results?
--
Richard Huxton
Archonet Ltd