Results 1 to 3 of 3

Thread: unable to execute query in many to one relationship

  1. #1
    Join Date
    Feb 2009
    Posts
    1

    unable to execute query in many to one relationship

    there are two tables

    marks table :

    rollno marks
    1 50
    1 80
    1 60

    and

    student table
    rollno name totalmarks
    1 pankaj 190


    i just want to show whether the sum of marks in marks table is equal to student table.

    In that case the query would be
    select sum(mk.marks),std.totalmarks from marks mk,student std where mk.rollno=std.rollno;

    but its not giving me output.

    what would be the solution.

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932

  3. #3
    Join Date
    Apr 2009
    Posts
    20
    SELECT
    S.ROLLNO, S.TOTALMARKS, SUM(M.MARKS)
    FROM
    MARKS M, STUDENT S
    WHERE
    M.ROLLNO = S.ROLLNO
    GROUP BY S.ROLLNO,S.TOTALMARKS


    reply me when you got the output as required.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •