Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Sorting by a group by


Message #1 by "Jeff Johnstone" <jjohnstone@c...> on Thu, 31 May 2001 16:45:17
Hello, I have given up.....

I have two files
Companies and Calls (many calls to one company)

and select for say,rep 12, and only open calls and this works great :-

SELECT TblCompanies.*
FROM TblCompanies
WHERE (((TblCompanies.Rep)=12) AND ((TblCompanies.ID) In (Select IdLinkKey 
from TblCalls where Closed = 0)))

However I want to sort by the newest call date in the Calls file. ie:-

SELECT Max(TblCalls.CallDate) AS MaxOfCallDate
FROM TblCalls
GROUP BY TblCalls.IDLinkKey

this would work fine.

Can I join all this together in once piece of SQL or do I need to write a 
little piece of code, or heaven forbid have a query ontop of a query ontop 
of a query...etc........I hate doing that.
I would really like to solve it with a single SQL string if possible.

PS : i am using Access2000 / VBA and SQL server 7

In anticipation 

Jeff

  Return to Index