SQL help

Reply

Join Date: Nov 2009
Posts: 2
Reputation: cjmartin is an unknown quantity at this point 
Solved Threads: 0
cjmartin cjmartin is offline Offline
Newbie Poster

SQL help

 
0
  #1
25 Days Ago
I have tried several different things with none providing the correct results. Any help is appreciated.

I have the following:
Table A Table B
Pallet_No Pallet_No
Qty Qty

I need to return:
- All of the Pallet_No's from Table A that are not in Table B
- All of the Pallet_No's from Table B that are not in Table A
- All the Pallet_No's where there is a difference in Qty b/w Table A and Table B.

Thanks for your help.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,093
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 126
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic
 
0
  #2
25 Days Ago
would you mind to post here what are the different things that you have tried ?
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: cjmartin is an unknown quantity at this point 
Solved Threads: 0
cjmartin cjmartin is offline Offline
Newbie Poster
 
0
  #3
25 Days Ago
Originally Posted by debasisdas View Post
would you mind to post here what are the different things that you have tried ?
Here is some of the SQL I have done to try to get this to work.

  1. SELECT e.EMPLOYEE_NAME, count(w.pallet_no) FROM pca_wms_fg w, kr_employee_v e
  2. WHERE trunc (w.modified_date) >= TO_DATE('10/18/2009','mm/dd/yyyy')
  3. AND trunc (w.modified_date) <= TO_DATE('10/21/2009','mm/dd/yyyy')
  4. AND w.MODIFIED_BY = e.BADGENUM
  5. GROUP BY e.employee_name

-----------------
  1. SELECT e.EMPLOYEE_NAME, e.badgenum, count(w.pallet_no), sum(QTY)
  2. FROM pca_wms_fg w, kr_employee_v e
  3. WHERE trunc (w.modified_date) >= TO_DATE('10/18/2009','mm/dd/yyyy')
  4. AND trunc (w.modified_date) <= TO_DATE('10/23/2009','mm/dd/yyyy')
  5. AND w.MODIFIED_BY = e.BADGENUM
  6. GROUP BY e.employee_name, e.badgenum

-------------
  1. SELECT employee_name, NbrPallets, CartonQty, OrderQty FROM (
  2. SELECT employee_name, count(pallet_no) NbrPallets, sum(QTY)CartonQty, sum(qty) OrderQty FROM (
  3. SELECT EMPLOYEE_NAME, w.pallet_no, w.QTY, 0
  4. FROM pca_wms_fg w, kr_employee_v e
  5. WHERE trunc (w.modified_date) >= TO_DATE('10/18/2009','mm/dd/yyyy')
  6. AND trunc (w.modified_date) <= TO_DATE('10/23/2009','mm/dd/yyyy')
  7. AND w.MODIFIED_BY = e.BADGENUM
  8. GROUP BY e.employee_name
  9. UNION all
  10. SELECT employee_name, '', 0, w.qty
  11. FROM pca_wms_fg w JOIN kr_employee_v e
  12. on w.modified_by = e.badgenum
  13. WHERE w.location_to LIKE ('6%')
  14. AND trunc (w.modified_date) >= TO_DATE('10/18/2009','mm/dd/yyyy')
  15. AND trunc (w.modified_date) <= TO_DATE('10/23/2009','mm/dd/yyyy')
  16. )
  17. GROUP BY employee_name, w.pallet_no
  18. )

------------
  1. SELECT pallet_no, decode(Qty1,0,Qty2,Qty1) QTY FROM (
  2. SELECT pallet_no, sum(QTY) Qty1, sum(LOCT_ONHAND)Qty2 FROM (
  3. SELECT pallet_no, QTY, 0 LOCT_ONHAND FROM pca_wms_fg
  4. UNION all
  5. SELECT SUBLOT_NO pallet_no , 0, LOCT_ONHAND FROM XXPCA_INVENTORY_V@tLK
  6. )
  7. GROUP BY pallet_no
  8. )

Thanks.
Last edited by peter_budo; 23 Days Ago at 6:13 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,093
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 126
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic
 
0
  #4
24 Days Ago
Try to use set operator, that should solve your Qry1 and Qry2.

for the third qry try to join both the tables.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the Oracle Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC