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 |
|
PolarBear
Starting Member
5 Posts |
Posted - 2009-02-17 : 13:06:10
|
| I need to run a query/script based on data similar to below:Hours_ID Memb_ID Work_Hrs Home_Hrs456 1234 40 15786 1234 20621 1234 10452 652 10 60442 652 15 30I need to total all hours as follows and include a Total_Hours column as follows:Memb_ID Work_Hrs Home_Hrs Total_Hhours1234 60 25 105652 25 90 115Any assistance would be appreciated |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2009-02-17 : 13:14:23
|
| select memb_id,sum(work_hours) WorkHours,sum(home_hours)HomeHours,sum(work_hours + home_hours)TotalHours from #temp group by memb_idMike"oh, that monkey is going to pay" |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-17 : 13:43:36
|
Your Expected output should be:Memb_ID Work_Hrs Home_Hrs Total_Hhours1234 60 25 85652 25 90 115 |
 |
|
|
PolarBear
Starting Member
5 Posts |
Posted - 2009-02-17 : 16:23:53
|
| Thanks for the quick reply. That was a great help!PolarBear |
 |
|
|
|
|
|