Results 1 to 3 of 3

Thread: query help

  1. #1
    Join Date
    Nov 2011

    Unanswered: query help

    I have two tables one with clients and one with orders. A client may have several orders with different ID made on the same day and I forward those orders to the foctory. Each order has a status field 1-> send to factory 2->received. I want to create a query that returns the orders that are received but only when all the orders from the same clients are ready. If one order of a client is still to the factory I have to wait for it and not send each order saperatelly.
    Can you help with this?

    Thank you.

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    does this work?

    SELECT A.*, B.*
    FROM tablesOneWithClients AS A
    LEFT JOIN tablesOneWithOrders AS B
    ON A.ClientIDfieldWhateverItIsCalled = B.ClientIDfieldWhateverItIsCalled
    WHERE A.ClientIDfieldWhateverItIsCalled NOT IN
    SELECT C.ClientIDfieldWhateverItIsCalled
    FROM tablesOneWithOrders AS C
    WHERE C.OrderStatusFieldWhateverItIsCalled = 1

    depending on how 'status' works you may need
    WHERE C.OrderStatusFieldWhateverItIsCalled <> 2
    or maybe
    WHERE C.OrderStatusFieldWhateverItIsCalled < 2

    currently using SS 2008R2

  3. #3
    Join Date
    Nov 2011
    thank you thank you

Posting Permissions

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