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
 General SQL Server Forums
 New to SQL Server Programming
 need sum of a particular item

Author  Topic 

Anushka
Yak Posting Veteran

79 Posts

Posted - 2008-04-23 : 04:38:01
select i.a,
w.c,
w.e
from table1 i,table2 w where
i.a=w.a (Here c is the primary key for each a)-iam getting o/p like this

a c e

aaa x 2
aaa y 10
bbb y 5
ccc x 3
ccc y 4

i need o/p in this way (ie sum of e for each a)
a e
aaa 12
bbb 5
ccc 7

Is it possible

Thanx

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-04-23 : 04:56:11
Something like...

select i.a, sum(w.e) as e from table1 i inner join table2 w on i.a = w.a group by i.a


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -