0
I wonder if there is a way I can make a query where I can bring fields that are not in my group by
.
I have the following code:
select sum(TAB_FATURAMENTO.vl_item),CLIENTE.insc_cnpj
from TAB_FATURAMENTO
inner join (IMP_PROCESSO
inner join CLIENTE
on IMP_PROCESSO.cd_cliente = CLIENTE.codigo)
on TAB_FATURAMENTO.cd_processo = IMP_PROCESSO.cd_processo
where TAB_FATURAMENTO.cd_cliente like '%'
and TAB_FATURAMENTO.pg='S'
group by CLIENTE.insc_cnpj
In my select
I would like to bring two more fields, but the grouping I want to stay only by customers CNPJ.
What fields? Would be different values within the same client?
– Rovann Linhalis
Yes, it would be different values, @Rovannlinhalis. In this case, I have clients with two CNPJ’s with the same reason, with different addresses, as well as the opposite.
– Tony Anderson
I see no problem, already tried to put
sum(X), cnpj, razao, endereco
with group bycnpj, razao, endereco
I believe it will be the way you need it– Rovann Linhalis