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

Using MAX with COUNT

Status
Not open for further replies.

shauns1

Programmer
Oct 21, 2005
53
AU
Hi

This is what I'm trying to do:

Select Name
From tblDevelopments
Where DevelopmentID = Max(
SELECT tblPFTopics.DevelopmentID, Count(*) as TotalDev
FROM tblPFEntries, tblPFTopics, tblPFThreads
WHERE tblPFTopics.TopicID =tblPFThreads.TopicID AND tblPFThreads.ThreadID=tblPFEntries.ThreadID
Group By tblPFTopics.DevelopmentID)

But as you probably already know, I can't use MAX in the WHERE clause.

What is the best way to go about this?

Many thanks

Shaun
 
Perhaps this ?
Select Name
From tblDevelopments
Where DevelopmentID = (
SELECT Max(tblPFTopics.DevelopmentID)
FROM tblPFEntries, tblPFTopics, tblPFThreads
WHERE tblPFTopics.TopicID =tblPFThreads.TopicID AND tblPFThreads.ThreadID=tblPFEntries.ThreadID
)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top