Table shown here shows the separate marks for each subject of each student. We can group these students to find the total marks of each student.

Code Snippet

SELECT NAME ,sum (MARKS) AS MARKS FROM TableName GROUP BY Name

Then we need to multiply the result that we get on dividing MARKS by TOTAL .This gives the percentage of marks obtained by each student.I.e., In case of Pavitra, we need to divide 21 by 30 which is suppose to be the Total marks.So (21/30) gives .77.Multiply .77 by 100 which gives the total percentage 77

Code Snippet

SELECT NAME ,(convert(float,(sum (MARKS)))/convert(float,@total))* 100 as PERCENTAGE_MARKS FROM #t1 GROUP BY Name

HappyCoding ! 😉

### Like this:

Like Loading...

*Related*

Posted by Tam on May 6, 2013 at 4:02 AM

When I initially commented I clicked the “Notify me when new comments are added”

checkbox and now each time a comment is added I

get three e-mails with the same comment. Is there any way you can remove me from that service?

Thank you!