SUM function with multiple table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siva07
    New Member
    • Jul 2007
    • 7

    #1

    SUM function with multiple table

    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
    Recognized Expert Contributor
    • Jul 2006
    • 802

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

    Comment

    Working...