get newest rows with a GROUP BY
From: Jan <jleimeister.tsystems_at_nvag.de>
Date: 19 Feb 2002 07:15:49 -0800
Message-ID: <3553dcc6.0202190715.371b1350_at_posting.google.com>
Date: 19 Feb 2002 07:15:49 -0800
Message-ID: <3553dcc6.0202190715.371b1350_at_posting.google.com>
Hi there,
I have a table with 2 foreign keys, a date column and several other
columns. I want to retrieve all the newest rows for each combination
of the foreign keys, but I need the other data as well. I could join
the table with itself (the combination of the foreign keys and the
date is an alternate key to the table),
but maybe/probably there is a better solution.
My SELECT-Stmt:
SELECT fk1, fk2, max(date) from table_name
group by fk1, fk2
Has anybody an idea?
Cheers,
Jan Received on Tue Feb 19 2002 - 16:15:49 CET
