Let us learn about the SUM sql command and how to use it in our tables. SUM
command can be applied to numeric field and the total of the value is returned.
Now let us apply this SUM command to this table and find out the total mark
obtain by all the students. The SUM command will add all the values of the mark
field and return to us. This is our table
Video Tutorial on Sum of Column values using GROUP BY , IN & CASE
We will apply the SUM command here like this to the field mark
SELECT sum( mark ) FROM `student`
The command added all the values of the mark field and displayed. We can define
some header like this also.
SELECT SUM(mark) as total_mark FROM `student`
GROUP By with SUM Query
Now let us find out what is the total mark in each class. Here we can use the Group
By command to find out the total mark obtained by each class
SELECT class, sum( mark ) as total_mark FROM`student` GROUP BY class
You can see above that total mark of each class is displayed. Since we have two
class in our table so the sql command has returned two class with total marks in
each of them. We have to use Group
By clause if we ask for the query to return any other field name other than
the sum. Otherwise system will generate error.
Hi! can someone tell me how to sum two or more rows from one table but different categories?I have a table that summarises my sales per category but i want to generate a report that summarizes all the items sold per category and return it in one single row.Please help
how to lisi a record from second to fifth from mysql db in php???
SELECT ACCOUNTTITLE,sum(debit),sum(credit) FROM `FIXEDJOURNALDTL` GROUP BY ACCOUNTTITLE
after getting the sum of column value in grid view .i want to display in text box.pls guard me...
Thank you for your tutorial.But I need id 1 to 4 sum values only, if any options is there? please tel...
Added this part by using SQL IN
thank you for an excellent explanation!
how to get Sum after Round a field in Group Clause
Select Sum (Round (Field ,2)) from Tabel Gruop By.....
I have selected and listed ProductId,ProductName,Price
WHERE Price >= 50.00
Now how do I get a total of this while still retaining the listed items
Thanks in Advance