Link to home
Start Free TrialLog in
Avatar of stephenz43
stephenz43

asked on

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 ?

Avatar of guidway
guidway
Flag of United States of America image

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;
Avatar of stephenz43
stephenz43

ASKER

hey guidway....

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

steve
you could try a subquery

Select acct_id from [sometableName] where acct_id < (Select max(acct_id) from [sometableName]) order by acct_id DESC
ASKER CERTIFIED SOLUTION
Avatar of guidway
guidway
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops you said access... sorry. ;)
max function does work in access i believe
glad it worked for you. :)
thank you for the help...You saved me alot of aggravation

take care