I made a query that brings the values of credit and debit, but I need to bring only the values that are different from these two fields. At the moment I do not know why he is bringing everyone. Look at the image: OBS IS IN SQL SERVER
sql code:
declare @data date='2018-05-21'
select * from (select sum (ContabLancValor) as debito,ContabLancNumCtrl,
CAST(ContabLancHistComp AS varchar(max)) as NomeCliente from
CONTAB_LANCAMENTO
where ContabLancData >=@data
and ContabLancData <=@data
and ContabLancCtaCred is not null
and EmpCod='01.02'
group by CAST(ContabLancHistComp AS varchar(max)), ContabLancNumCtrl)debito
inner join(
select sum (ContabLancValor) as credito,ContabLancNumCtrl from
CONTAB_LANCAMENTO
where ContabLancData >=@data
and ContabLancData <=@data
and ContabLancCtaDeb is not null
and EmpCod='01.02'
group by CAST(ContabLancHistComp AS varchar(max)), ContabLancNumCtrl) credito
on credito.ContabLancNumCtrl=debito.ContabLancNumCtrl
where debito.debito<>credito.credito