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

Where clauses and aggregate functions.....

Status
Not open for further replies.

KellyJo

Technical User
Sep 14, 2004
24
US
Can anyone tell me how to fix this code so that it works? You can't have an aggregate function in a where clause.

s = "SELECT [ID] as PK, ERName AS ERName FROM [Staffing Data] WHERE [ID] = max([ID])"

Thanks!

KellyJo

 
That's not code, that's SQL, there is a forum for queries and sql (forum701)

[tt]...where id=(select max(id) from [staffing data])[/tt]

or

[tt]select top 1 id as pk <rest of statement> order by id desc[/tt]

Roy-Vidar
 
s = "SELECT [ID] as PK, ERName AS ERName FROM [Staffing Data] WHERE [ID] = dmax("[ID]","Staffing Data")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top