Stored Procedure

15 pts.
Tags:
SQL stored procedures
Stored Procedures
Hi Guys. Any help would be greatly appreciated. I have three tables Table 1 ID PurchaseOrderNo Value Table 2 ID PurchaseOrderNo WorkID Table 3 WorkID Cost Tables 2 and 3 have a many to one relationship with table 1. I want to display all the PurchaseOrderNo from table 1 and then the sum of Costs from table 3 using the link provided by table 2. Is this possible? Thanks in advance for any help or advice

Answer Wiki

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

I think this is what you need:

<pre>SELECT t1.PurchaseOrderNo, SUM(t3.Cost)
FROM table1 t1 JOIN table2 t2
ON t1.PurchaseOrderNo = t2.PurchaseOrderNo
JOIN table3 t3
ON t2.WorkID = t3.WorkID
GROUP BY t1.PurchaseOrderNo</pre>

Discuss This Question: 1  Reply

 
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
  • Andy1999972
    Thanks Carlos
    15 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