I have data in this manner
ID SUB Marks
1 English 25
1 Maths 22
1 Science 15
2 English 16
2 Maths 20
2 Science 12
And so on...
How would I sum all subject marks and give total marks of each ID?
For example, if I select ID=1 then it should show 62.
select id, sum(Marks) as marks
from tablename
group by id
Try this... this is working...
SELECT ID, SUM(Marks) as Total
FROM Table_Name
GROUP BY ID
ORDER BY ID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With