Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2010-09-17 : 05:00:13
|
| Good day friends,Hope you are all well.I am having trouble at attempting to create an output from 2 tables.Basically I have 2 tables - TB_Project - contains Project_ID, Project_nameTB_Stage - Contains Stage_id, Project_ID, Stage_Cost(money type)1 Project has multiple stagesI was trying to join the details into a temptable where I would get the project name and the project cost(all of the stage costs added together)SELECT Project_id, Project_name, (....)from tb_projectsbut what do I put in the brackets that can add the stage_costs together.Any assistance would be greatly received.Thank you for your time. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-17 : 05:40:45
|
selectp.Project_ID,p.Project_name,dt.Project_Costfrom TB_Project as pjoin(select Project_ID, sum(Stage_Cost) as Project_Costfrom TB_Stagegroup by Project_ID) as dton dt.Project_ID = p.Project_ID No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-09-17 : 05:55:07
|
ORselectp.Project_ID,p.Project_name,SUM(s.Project_Cost)over() TotalCostfrom TB_Project as pjoin TB_Stage son s.Project_ID = p.Project_ID Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
|
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2010-09-17 : 06:01:33
|
| Thank you very much guys :) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-17 : 06:07:50
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|