-
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
-
Hint: Use GROUP BY and SUM.
-
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
-
Forum Rules
|
|