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

Select MAX and MAX minus 1

Status
Not open for further replies.

thorny00

Programmer
Feb 20, 2003
122
US
I have the following query, but I need to change the bathcid's each week. Is there a way to select the MAX batchid and the MAX batchid minus 1?

select distinct pin from IN_Carolina_834Elig
where convert (datetime,dob) = convert(datetime, '<<bthdat>>') and SSN = '<<Calc_MemberID>>'
and batchid in (8024, 8028)

Thanks in advance for your time and help, it is greatly appreciated.
 
Code:
select distinct pin
        from IN_Carolina_834Elig
where convert (datetime,dob) = convert(datetime, '<<bthdat>>')
and SSN = '<<Calc_MemberID>>'
and batchid > (SELECT MAX(BatchId) FROM ...)-2


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top