Can anyone help me with this query, please? I'm having a hard time organizing this 'Case when' I think
CREDITO | CONTA | TIPO
100 8 ENTRADA
30 9 ENTRADA
30 10 ENTRADA
1 8 SAIDA
10 11 ENTRADA
1 8 SAIDA
1 11 SAIDA
10 12 ENTRADA
15 12 ENTRADA
15 13 ENTRADA
look where I want to go, it's the first time I try a more different query, so to speak.
select c, sum(pos), sum(negat) from(
select conta as c,
Case when (tipo = 'ENTRADA') then sum(credito) end pos,
Case when (tipo = 'SAIDA') then sum(credito) end negat
from credito
) A group by c;
I need to get all the accounts in a distinct and on the same line have the list
Conta | TotalCreditosEntrada | TotalCreditosSaida