Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query to perform like Minus statement

Mark CooperSep 6 2012 — edited Sep 26 2012
Hi Guys,

I have an issue to ask. I need to extract the final issued parts from a table. Table stores the issue and unissue parts.

e.g lets say 4 items have been issued and 3 items have been un-issued from a table. so in last 1 items should be resulted. while I am executing the following code its not working correctly.

Table data:
REPAIRED_ITEM_ID 	ISSUED_REMOVED_ PART_ID	Oper_ID	QTY
122013187	                 1323938	                                  308	        1
122013187	                 1323938	                                  308	        1
122013187	                 1323938	                                  309	        1
122013187	                 1323940	                                  308	        1
122013187             	 1323940	                                  308	        1
122013187	                 1323940	                                  309	        1
122013187	                 1323940	                                  309	        1



 SELECT * FROM WC1.ISSUED_REMOVED_ITEM IRI 
    WHERE 
    IRI.ORDER_ITEM_OPER_ID = 308 
    AND IRI.SES_CUSTOMER_ID =1
    AND IRI.REPAIRED_ITEM_ID =  122013187  
    AND 0 = (SELECT COUNT(1)
           FROM WC1.ISSUED_REMOVED_ITEM U
           WHERE U.REPAIRED_ITEM_ID =  IRI.REPAIRED_ITEM_ID 
           AND U.ORDER_ITEM_OPER_ID = 309
           AND U.SES_CUSTOMER_ID= 1
           )
But the above query is not showing any result, while it should show 1 record of 1323938 , Can anyone please explain me how to get this right result?


Note: Repair Item id is unique of MAIN UNIT. which can contains multiple issue and un-issue of dependent units.

Many Thanks,

M.C.

Edited by: BluShadow on 06-Sep-2012 13:19
added {noformat}
{noformat} tags to help readability.  Please read {message:id=9360002} and learn to post questions with format in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
This post has been answered by Centinul on Sep 6 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 24 2012
Added on Sep 6 2012
21 comments
193 views