5
In this consultation, in ,SUM(quota_re_mes1) AS NO_MES
i would like it to add up only the positive numbers, is there any way to do that?
SELECT orcdotac.conta_desp
,orcplade.descricao
,orcplade.complemento
,SUM(orcdotac.sld_orc_ano) AS CREDITOS_ORCAMENTARIOS
,(SUM(orcdotac.SLD_ORC_ANO) + SUM(orcdotac.SLD_SUPL_ANO) + SUM(orcdotac.SLD_ESP_ANO) + SUM(orcdotac.SLD_EXT_ANO)) - SUM(orcdotac.SLD_RE_ANO) AS SALDO_ORCAMENTARIO
,SUM(quota_re_mes1) AS NO_MES
,(SUM(orcdotac.SLD_EMP_EMPEN) - SUM(orcdotac.SLD_EMP_ANULADO)) AS NO_ANO
,(SUM(orcdotac.SLD_ORC_ANO) + SUM(orcdotac.SLD_SUPL_ANO) + SUM(orcdotac.SLD_ESP_ANO) + SUM(orcdotac.SLD_EXT_ANO)) - SUM(orcdotac.SLD_RE_ANO) - (SUM(orcdotac.SLD_EMP_EMPEN) - SUM(orcdotac.SLD_EMP_ANULADO)) AS DIFERENCAS
FROM orcdotac
LEFT JOIN orcplade ON
(orcdotac.conta_desp = orcplade.conta_desp)
WHERE orcdotac.conta_desp IS NOT NULL and codigo_tipo = 1
GROUP BY orcdotac.conta_desp, orcdotac.sub_item, orcplade.descricao, orcplade.complemento
ORDER BY conta_desp
wow, so easy... but I couldn’t find anything like this on google hahaha
– V.Avancini