Experts,
Need some help with query.
Order table:
OrderNo, ItemNo, ItemStatus
1234 , 56566, Sent
1234, 44545, Hold
1234, 67888, Processing
4567 , 65656, Sent
4567 , 45466, Hold
4566, 34566, Hold
Transaction Table:
Order No, Item No, Sub Item no, SubitemStatus
1234 , 56566, 5656601, Sent
1234 , 56566, 5656602, Sent
1234 , 44545, 4454501, Sent
1234 , 44545, 4454502, Sent
1234, 67888, 6788801, Sent
4567 , 65656, 6565601 Hold
4567 , 45466, 4546601 Sent
4567 , 45466, 4546602 Processing
4566, 34566, 3456601 Sent
4566, 34566, 3456602 Sent
Basically, i want to return only the records for the SubitemsStatus= "Sent" each record for the Order should be Sent status, if one record is 'sent' and other is 'Processing' 'hold' etc. than exclude the entire order no. For the above table. My result set should return..
Order No, 1234 and 4566. Order 4567 should not be returned as one of the record Status is 'Hold' and 'processing'.
Thanks in advance.
Open in new window
Using a GROUP BY and HAVING clause will allow you to find only those where all are sent.
You haven't specified what the "expected result" should look like so I have just assumed you want rows from the orders table.
details:
Open in new window