Connecting Tech Pros Worldwide Help | Site Map

SUM function with multiple table

Newbie
 
Join Date: Jul 2007
Posts: 7
#1: Aug 3 '07
Hi Experts,

I have two table called T1 and T2

T1


shipid--------------amount
1 -------------------- 100
2-------------------- 10
3-------------------- 50



T2

Artist--------------------shipid

A1----------------------------2
A1----------------------------3
A2----------------------------1

My OutPut will be sum(amount) group by Artist

that is,

A1-------------60
A2-------------10

For that i am using

my $cStr="select sum(t1.amount) from t1,t2 group by t2.artist";

but it is not working.


Is any Idea,
mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 718
#2: Aug 4 '07

re: SUM function with multiple table


You have to JOIN the tables with a common field (a field which is present in both tables).
Reply