If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I have to select 10 variables from a table. 6 of these variables, together
make up a unique identifier for a row, the sixth variable is a date.
Often the other 5 variables will be identical across rows.
Now my question:
How do I select all unique rows on from the table,
but only the rows with the recentmost date, if the rows are duplicates
(on the 5 variables) ?
All thougths are appreciated.
__________________
Kristian K. Hansen
Project Supervisor
National Board of Health
aloz, that works only if col1 through col5 are the only columns you want to return in the row along with the max date
my solution allows you to add additional columns to the SELECT list
you cannot just add columns to your SELECT list, because then they'd also have to go into the GROUP BY, and since they would not be part of the primary key, the rows you get back could then duplicate the primary key columns