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!

select max-1

Status
Not open for further replies.

pgoulet

IS-IT--Management
Dec 9, 2002
45
US
Is it possible to select the max value -1?

Thanks in advance.
 
If you mean you want to subtract 1 from the maximum value:

select max (fieldname)-1 as fieldnameMinus1
from table

If you mean you want the second from top record in a field:

select top 2 fieldname
from table
order by fieldname desc

and ignore the second line in your code.

John
 
Wow, I certainly need to read up on how to ask a good question.

If you take a sorted list...

a,b,c,d,e,f,

and you wanted to get ONLY the value of max-1 or max-2, is there a way to do that? Meaning select e, or d respectively.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top