944,028 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 1120
  • Oracle RSS
Nov 3rd, 2009
0

SQL help

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Light Poster
cjmartin is offline Offline
41 posts
since Nov 2009
Nov 3rd, 2009
0
Re: SQL help
would you mind to post here what are the different things that you have tried ?
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Nov 3rd, 2009
0
Re: SQL help
Click to Expand / Collapse  Quote originally posted by debasisdas ...
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.

sql Syntax (Toggle Plain Text)
  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

-----------------
sql Syntax (Toggle Plain Text)
  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

-------------
sql Syntax (Toggle Plain Text)
  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. )

------------
sql Syntax (Toggle Plain Text)
  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; Nov 5th, 2009 at 6:13 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reputation Points: 10
Solved Threads: 0
Light Poster
cjmartin is offline Offline
41 posts
since Nov 2009
Nov 4th, 2009
0
Re: SQL help
Try to use set operator, that should solve your Qry1 and Qry2.

for the third qry try to join both the tables.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: dbms
Next Thread in Oracle Forum Timeline: what is the difference between deny and revoke?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC