Results 1 to 8 of 8

Thread: Please help with query - left join same table twice different conditions and count

Threaded View

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Please help with query - left join same table twice different conditions and count

    Worked on this yesterday afternoon and all morning today; guess it's time to get help
    I have a table which contains high level information on an order placed by a customer - xtblMROrder
    I have another table xtblMROrderSerialNumbers which contains 1 or more rows that fulfill the order.
    When we receive from our vendor the items, we create rows in xtblMROrderSerialNumbers. Also in this table is a column ReleasedMethod when we send the items out to the customer. It is null if we haven't released that item yet.
    So here's the state of my data.
    1) I have a row in xtlbMROrder with key Control = 36862 and QuantityOrdered = 4.
    2) I have 4 rows in xtblMROrderSerialNumbers that are MROrderMasterControl = 36862. Three items have been released to the customer, one has not. Picture below. (I x'd out Serial Number but they are unique).

    I want to get a count of released items (3) and remaining items (1). My query is giving me a value of 3 for both counts. I cannot figure out what is wrong. I do know that if I comment out one of the COUNT's and its associated table, I get the correct value in the other count. So it has to have something to do with my join to the same table twice but I don't see it.

    Thank you!
    Attached Images Attached Images  
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

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



Click Here to Expand Forum to Full Width