Alex,
> which is the highest value of 'sortby' for each value of 'fk'.
>
> I would think that the SQL to achieve this is:
>
> SELECT * FROM test GROUP BY fk HAVING sortby = MAX(sortby);
You need a subselect for this:
SELECT test.*
FROM test, (SELECT max(sortby) as maxsort, fk
"Alex Page" <[EMAIL PROTECTED]> writes:
> I'm trying to write a query that returns the rows containing the
> most recent values for each foreign key.
The best way to do this (on every dimension except portability :-()
is SELECT DISTINCT ON. See the weather-report example in the SELECT
reference