15 pts.
0
Q:
Stored Procedure
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
ASKED: Apr 24 2009  3:15 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
29340 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
I think this is what you need:

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
Last Answered: Apr 24 2009  4:11 PM GMT by Carlosdl   29340 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Andy1999972   15 pts.  |   Apr 27 2009  12:37PM GMT

Thanks Carlos

 
0