How to get the sum of the column?
Posted: Tue Dec 29, 2009 10:52 am
How to get the sum of the column, for example like in the photo?


A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/

Code: Select all
$query1 = "SELECT Muaji, Fitimi, Bortxh, Fitimi_Total from TABLE";
$query2 = "SELECT Sum(Fitimi_Total) from TABLE ";Code: Select all
select label, b, c, d, sum(b + c + d) from scratch group by label with rollupI think that there is a problem to do this, Because to show this data in the table, I use the above code. To be more clear, I have all the sales in a table in MySQL, then Here I collect all the sales from "November - 2009", "December 2009" etc... So Now I want to calculate all the sales of 2009, all the sales that are in the Table(in photo).manohoo wrote:When I learned Oracle's SQL there was a REPORT feature that allowed you to do what you want. However, in MySQL the only way that I know how is to run 2 separate queries. In your case it would be something like this:
Then do your usual HTML/PHP to bring'em together into a table.Code: Select all
$query1 = "SELECT Muaji, Fitimi, Bortxh, Fitimi_Total from TABLE"; $query2 = "SELECT Sum(Fitimi_Total) from TABLE ";
Code: Select all
$sql = mysql_query("SELECT SUM(qtotal), SUM(borxh), DATE_FORMAT(data, '%m/%Y') AS dataere FROM riparimet GROUP BY dataere ORDER BY data DESC");Code: Select all
$sql = mysql_query("SELECT Sum(Fitimi_Total) from TABLE");