I have this code :
select
B.plc_nomeConta, B.plc_classificador, B.plc_id,
A.cap_idPlanoContasFin, SUM(A.cap_valorfatura) as Total
from
tbl_PlanoFinanceiro B
left outer join erp_contaspagar A on B.plc_id = A.cap_idPlanoContasFin
/* where A.cap_idEmpresa like 2*/
group by
B.plc_nomeConta,
B.plc_classificador,
B.plc_id,
A.cap_idPlanoContasFin
This code returns 185 Lines,
(-) COFINS 10.01.01.01.004 330 330 971090,97
(-) ICMS 10.01.01.01.002 328 328 1378407,11
(-) IMPOSTOS 10.01.00.00.000 324 NULL NULL
(-) IMPOSTOS 10.01.01.00.000 325 NULL NULL
(-) IMPOSTOS 10.01.01.01.000 326 NULL NULL
(-) ISS 10.01.01.01.001 327 327 1000960,59
(-) PIS 10.01.01.01.003 329 329 240600,27
but when I uncomment the where /* where A.cap_idEmpresa like 2*/
, returns only the lines where A.cap_idPlanoContasFin is not null
, In need ever B.plc_nomeConta, B.plc_classificador, B.plc_id
appears.