sql for two table

  • I have two table

    1> Master

    2 > Detail

    fields are

    Master : - code,Name , elcl _grant ,ol_grant

    Detail : code, elcl, ol

    e.g.

    data     code      Name        elcl_grant   Ol_Grant master : 1>1001 Shantaram       10            20

                 2> 1002 Deepak        10             20

    Detail   :

                       code    elcl   ol

                       1001     2     0

                       1002     1     1

                       1002      3    0

    I want following result

    Name      Elcl Grant OL _Grant Elcl_given  Ol Given Shantaram   10              20           2               0

    Deepak        10              20          4               1

    Waiting for your valuable suggestion

  • SELECT Name, Elcl_grant, ol_grant, sum(elcl) as elcl_given, sum(ol) as ol_given

    FROM Master

    JOIN Detail ON master.code = detail.code

    GROUP by Name, Elcl_grant, ol_grant

     


    Regards,

    Meghana

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply