Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL to select most recent row from current date.

Status
Not open for further replies.

davism

MIS
Nov 9, 2002
140
US
Hi,

I have a table with something like:

MemberID[tab][tab]EffDate[tab][tab]TermDate
-----------------------------------------------
1[tab][tab][tab][tab]12/01/2018[tab][tab]12/31/2018
1[tab][tab][tab][tab]4/01/2019[tab][tab]5/31/2019
1[tab][tab][tab][tab]7/01/2019[tab][tab]12/31/2019

I want to get the one that is *not* already termed but the most recent to today.

That would be the:
1[tab][tab][tab][tab]4/01/2019[tab][tab]5/31/2019

I can't use a MAX on that. How would/could I go about this?

Any info would be greatly appreciated.

Thanks
 
Based on your example:

[tt]Select * from ATable
WHERE TermDate =
(Select Min(TermDate) From ATable
Where TermDate > Today)[/tt]


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top