Hello all,
I have a Journal_Entry table, with a Primary Key of Journal_Entry_ID, and (among other columns) an Entry_Date column.
I'm trying to do a query that selects the most recent Entry_Date -- via a SELECT MAX(Entry_Date)
-- but the problem is that the user may have logged more than one entry on a given date. So if the user logged a journal entry twice today, this SELECT statement could return more than one row because the same MAX Entry_Date has been logged more than once.
So what I'd like to do is, if the SELECT MAX statement returns more than one record, choose the record that has the highest Journal_Entry_ID of the ones returned.
Right now my query looks like this:
SELECT Journal_Entry_ID, Entry_Date
FROM Journal_Entry
WHERE Entry_Date = (SELECT MAX(Entry_Date) FROM Journal_Entry);
I'm using SQL SERVER. Any help would be greatly appreciated.
Thanks.
EDIT: I'm using SQL SERVER. Not My SQL as I had originally reported.