Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL LInks

Status
Not open for further replies.

lasd

Programmer
Jan 14, 2005
48
IE
Hi,
I am working on some SQL code for a report and from the code that i am copying in below i am getting back four lines. i know i am only supposed to be getting back two lines but can't see where the missing link it. Hopefully someone can help me.
thanks in advance for help.
greatly appreciated
lasd
SELECT PH.po_header_id C_PO_HEADER_ID,
PH.segment1 C_PO_NUM,
PH.rate C_RATE,
PH.creation_date C_CREATION_DATE,
PR.release_num C_PO_RELEASE_NUM,
PL.line_num C_PO_LINE_NUM,
PLL.shipment_num C_PO_SHIPMENT_NUM,
PD.distribution_num C_PO_DISTRIBUTION_NUM,
PD.quantity_ordered C_QUANTITY_ORDERED,
RSH.receipt_num C_RECEIPT_NUM3,
RSL.Quantity_received C_QUANTITY_RECEIVED3
FROM po_headers_all PH,
po_lines_all PL,
po_line_locations_all PLL,
po_distributions_all PD,
po_releases_all PR,
rcv_transactions RTXN,
rcv_shipment_headers RSH,
rcv_shipment_lines RSL
WHERE PH.po_header_id = PD.po_header_id
AND PD.line_location_id = PLL.line_location_id
AND PLL.po_line_id = PL.po_line_id
AND PD.po_header_id = PR.po_header_id (+)
AND RTXN.PO_DISTRIBUTION_ID=PD.PO_DISTRIBUTION_ID
AND RTXN.PO_LINE_ID=PL.PO_LINE_ID
AND RTXN.PO_LINE_LOCATION_ID=PLL.line_location_id
AND PH.po_header_id=RTXN.PO_HEADER_ID
AND RTXN.shipment_line_id=RSL.shipment_line_id
AND RSL.shipment_header_id=RSH.shipment_header_id
AND PH.SEGMENT1='182386'
 
Lasd,

Without having your seven tables available for troubleshooting, we can only make guesses as to why you are resulting in four rows instead of two. In the absence of having the tables, I can only say definitively that your problem is in your WHERE clause...if your receive too many rows, the WHERE clause is not restrictive enough. Alternately, if your problem is that two of your four rows are duplicates, then you can use the DISTINCT/UNIQUE modifier at the beginning of your SELECT's expression-list.

Let us know what your find.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
Providing low-cost remote Database Administration and support services

Do you use Oracle and live or work in Utah, USA?
Then click here to join Utah Oracle Users Group on Tek-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top