sql Next to last Record

Greeting

I cant figure out a query that retrieves only the next to last record where the account number = some value  ( not the last record inserted into the dbase)

Im using vb 2005 and access

Any idea's ?

stephenz43Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
guidwayConnect With a Mentor Commented:
should be a semicolon at the end

Select acct_id from [sometableName] where acct_id < (Select max(acct_id) from [sometableName]) order by acct_id DESC;

(this was tested in access, not sure which database you are using)
0
 
guidwayCommented:
I think this will work

Select acct_id from [sometableName] where acct_id < [some value] order by acct_id DESC;

then just grab the first record returned and that should be the second to last;
0
 
stephenz43Author Commented:
hey guidway....

Getting close, but can [some value] be obtained using max[acct_id) ?

steve
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
guidwayCommented:
you could try a subquery

Select acct_id from [sometableName] where acct_id < (Select max(acct_id) from [sometableName]) order by acct_id DESC
0
 
guidwayCommented:
oops you said access... sorry. ;)
0
 
newyuppieCommented:
max function does work in access i believe
0
 
guidwayCommented:
glad it worked for you. :)
0
 
stephenz43Author Commented:
thank you for the help...You saved me alot of aggravation

take care
0
All Courses

From novice to tech pro — start learning today.