Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-08-12 : 07:49:09
|
| Alex writes "I have 2 tables, Agents table and a Sales table both with a common field, AgentID, i'm trying to create a query that searches for those Agents who have not made any sales between 2 dates, i would figure the code below to work, BUT i get an empty response, can you help?Select * FROM AgentsQWHERE NOT EXISTS (SELECT *FROM SalesQWHERE ClosingDate BETWEEN #8/1/2004# AND #8/1/2005#) Order ByAgentOfficeID, Tier" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-08-12 : 07:52:09
|
| You did not corellate the subquery to the outer query:Select * FROM AgentsQ AWHERE NOT EXISTS (SELECT * FROM SalesQ B WHERE ClosingDate BETWEEN '8/1/2004' AND '8/1/2005' AND B.AgentID=A.AgentID) Order By AgentOfficeID, Tier" |
 |
|
|
|
|
|