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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to sum days......

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2010-05-30 : 17:07:26
hi,

I have two table
tbltask contains field like

id days
1 2
2 3
3 6

primary key = id

and another table tblTools which contains field like,
id toolid Reqid
1 1 1
2 2 2
3 2 3
foreign key= reqid

now i want to sum days depending upon toolid

i want result like

toolid days
1 2
2 9

Regards,
ASIF

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-05-30 : 21:41:58
[code]
select a.toolid, sum(b.days)
from tblTools a
inner join tblTask b on a.Reqid = b.id
group by a.toolid
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -