Results 1 to 2 of 2
  1. #1
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62

    Exclude any that match

    What I want to select is the sales rep name that doesn't have any orders with a specific customer.

    Sales Rep
    ID
    Name



    Customer
    ID
    Name
    etc info

    Order
    ID
    Sales_rep_id
    Cust_id
    etc..

    In this case I want the sales rep name that doesn't have any orders with customer "Bob." Initial pass eliminated including any order with Bob but it still returned the sales rep's name, ie if sales rep Steve had an order with Bob and Jack, his name was included. What I want is for Steve not to be included since he does have an order with Bob. I'm wondering if I should use something like IN or EXIST, or if there is another approach that would work.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Try:

    SELECT * FROM [Sales Rep] WHERE ID NOT IN (SELECT Sales_rep_id FROM Order WHERE Cust_id=[enter id here]);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Exclude IDs in grouped query
    By Ruegen in forum Queries
    Replies: 2
    Last Post: 09-02-2014, 09:27 PM
  2. Replies: 9
    Last Post: 06-13-2014, 12:50 PM
  3. exclude the most recent date
    By crowegreg in forum Queries
    Replies: 2
    Last Post: 10-22-2013, 09:53 AM
  4. VBA Code to exclude codes
    By kwooten in forum Programming
    Replies: 1
    Last Post: 09-10-2013, 10:39 AM
  5. Replies: 16
    Last Post: 03-13-2012, 03:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums