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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select One Record With the Highest Value Within a List

Status
Not open for further replies.

ihda

MIS
Apr 6, 2001
46
0
0
US
I have 5 records, each with a different expiration date:
20010601
20020520
20030316
20041230
20051007

I have to find the one record where the comparenumber is the highest value without exceeding the comparenumber

Example:
Comparenumber (from another table) = 2050206

I need to select only 20041230 since it is the highest value possible.

In my current query I'm selecting all records below 20051007 instead of 20041230 only.

Thank you.
 
Code:
SELECT max(comparenumber)
FROM   table
WHERE  comparenumber <= 2050206

There, that was easy! [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top