3
How could you perform a series of calculations directly in the sql query, as there is SUM()
that performs the sum would have some way to add one column to another and decrease another?
$sql02 = mysql_query("SELECT * , SUM(valor) as tt FROM finan ");
$dados02 = mysql_fetch_array($sql02);
$fev_c = $dados02[$pg];
$fev_v = $dados02[$pg];
$tot = $dados02['tt'];
$juros = $dados02['multa'];
$multa = $dados02['juros'];
$desconto = $dados02['desconto'];
// abaixo é o calculo que atualmente fasso é e isso que queria fazer direto na consulta
$fev2 = $tot+$juros+$multa-$desconto;
my question is it would have as this calculation already be made in the query
SELECT *, SUM(valor) as tt FROM finan;
It can, no problem. What was the difficulty found?
– Bacco
example SUM(value) as tt + SUM(interest) as jj + SUM(fine) as ss - SUM(discount) as dd how this would come about
– Fabio Henrique
It is an expression only, then it is an AS only. SUM(value) + SUM( ..... AS total.
– Bacco
Show worked here... I didn’t know SUM(value) + SUM( ..... worth
– Fabio Henrique