[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

Change Not In to Not Exists

I need to change this syntax to a NOT EXISTS statement

SELECT TOP 100 PERCENT
		dbo.CallData.CallID,
		Blah...blah...blah...
	FROM		dbo.CallData WITH (NOLOCK) 
	INNER JOIN	blah...blah..
	WHERE		dbo.CallData.[USER NAME] NOT IN (SELECT a.[Account Manager] AM									FROM	dbo.[Account Manager] a
                JOIN	dbo.[Staffing Manager] s
                          ON a.[Account Manager] = s.[Staffing Manager]
            WHERE	a.Status = 'Active')

Open in new window

0
lrbrister
Asked:
lrbrister
  • 2
  • 2
1 Solution
 
TempDBACommented:
SELECT TOP 100 PERCENT
            dbo.CD.CallID,
            Blah...blah...blah...
      FROM dbo.CallData WITH (NOLOCK) CD
      INNER JOIN      blah...blah..
      WHERE      NOT EXISTS
      (SELECT a.[Account Manager] AM      FROM dbo.[Account Manager] a
     JOIN dbo.[Staffing Manager] s
     ON a.[Account Manager] = s.[Staffing Manager]
     WHERE      a.Status = 'Active'
       AND a.[Account Manager] = CD.[USER NAME])
0
 
lrbristerAuthor Commented:
Thanks.

I had that...just wanted verification I was applying correctly
0
 
TempDBACommented:
Good to hear that. Thanks for the point and all the best with your work.
0
 
lrbristerAuthor Commented:
Yeah
Still blunder around at times with the
NOT IN
NOT EXISTS
and JOINS

And when it is most economical to use what
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now