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

Top Statement with Between statement problems sql or qbe Need Help 1

Status
Not open for further replies.

syoung4

Technical User
Feb 21, 2001
36
GB
I am trying to convert a large Sql Query that has Top statements. I think the query was a stored query on a remote network. I am trying to get the query working in Access 97.

this is the original code:
AND tblA537.DepotID BETWEEN @intDepotID AND @intTopDepotID
AND tblClient.ClientID BETWEEN @intClientID AND opClientID
AND tblcontract.ContractID BETWEEN @intContractID AND @intTopContractID

This is the start of my version below but I am having
trouble getting the top statment to work.

SELECT dbo_tblA537.DepotID
FROM dbo_tblA537
where dbo_tblA537.DepotID between TOP 1 dbo_tblA537.DepotID and dbo_tblA537.DepotID

Would anyone know how I could get this going.
Thank you.

Regards,
Sid
 
Presuming intTopContractID is the highest contractID you could use something like DMax to look up the highest value, e.g.
Code:
...DMax("ContractID","tblContract")...
instead of @intTopContractID
 
Thank you so much for your help I have managed to get it all going now.

regards,

Sid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top