SQL Server Query Help Needed

70 pts.
Tags:
INNER JOIN
JOIN statement
LEFT JOIN
RIGHT JOIN
SQL
SQL queries
SQL Query
SQL Server development
SQL Server Query
I have a table with Inventory transacation records. The table contains both Shipment (outgoing) and Receiving (incoming) transactions. I'm trying to write a report that lists both Sales Orders that result in Shipment records and Purchase Orders that result in Receiving records. If I link the Inventory Transaction table to the Shipment (Sales Order) tables and to the Receiving (Purchase Order) tables, I only get one or the other (Sales or Purchasing) records, not both. Is there a trick to this with Left, Inner and Right joins on the tables or do I need some other approach? Thanks for the help, Arlin
ASKED: February 5, 2009  10:39 PM
UPDATED: February 6, 2009  4:51 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

How about a UNION of two queries, one from sales,transactions (shipments) and the other from purchases,transactions (receivings) ?

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Sivu
    That depends on your data, if you are maintaining separate keys for sales and purchase orders of the each product then there should be no problem as such, else : 1. you do a full outer join on these tables with your inventory table 2. write a two queries for sales & purchase and run both with UNION ALL in between two SQLs.
    105 pointsBadges:
    report
  • Arlin
    Hi Sivu, I have GUID's in the Inventory Table for Sales and Purchasing. When I link the Sales table, I don't see the link I've made to the Purchasing table and vice versa. I'll try the Union All. Thanks for the tip. Arlin
    70 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following