Results 1 to 2 of 2

Thread: Finding who doesn't sell to a certain place...

  1. #1
    Join Date
    Dec 2010
    Posts
    1

    Finding who doesn't sell to a certain place...

    Hi all,

    I have a Vendor table which links to an Order table via VendorID. I have a Customer table that also links to the Order table via CustomerID.

    This means the order table provides a list of all orders, and the IDs of the Customers who made the orders, and the Vendors who handled the orders. For a given order, I can find the state that the customer is from (using Customer table's State field).

    This means I can get where the Vendor's sell too. I need to use a sql query to produce a list of vendor's that have NEVER sold to a customer New York. How do I do this? I just cannot get my head around it.

    Thanks.

  2. #2
    Join Date
    Feb 2011
    Posts
    3
    Hi ,

    You table structure must be like this

    Vendor_table (vendor_id , vendor_name)
    order_table(order_id , vendor_id , customer_id )
    customer_table (customer_id , state_name)

    SELECT vendor_name FROM vendor_table WHERE vendor_id IN
    (SELECT T1.vendor_id from order_table T1 , customer_table T2 WHERE T1.customer_id = T2.customer_id AND T2.state_name <> 'New York'
    )

    Let me know if you still face any problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •