I am doing a commission report, but a question arose, I want to bring some totals at the end of the report, for example the gross value of all commissions, which would be vl_comis - desc_comis
. Anyway, how do I create a column called total_valor_bruto
that returns the sum of all the raw values of the commissions table?
SELECT
a.id,
a.nf,
a.data_lcto,
a.data_prog,
a.data_pgto,
a.vl_comis,
a.desc_comis,
a.ir_comis,
a.vl_pgto,
a.pedido_comis,
b.Empresa as emp,
b.RazaoSocial as razao,
c.cod,
c.Representante as representante,
d.PeriodoID as periodo_comissao,
d.Periodo_inicial as inicial,
d.Periodo_final as final
FROM (((Comissoes a
INNER JOIN Empresas b ON a.EmpresaID = b.EmpresaID)
INNER JOIN Representantes c ON a.RepresentanteID = c.RepresentanteID)
INNER JOIN Periodos d ON a.PeriodoID = d.PeriodoID)
WHERE d.PeriodoID ='".$_COOKIE["cpr"]."' ORDER BY a.created");