1
I need to make a report and I am not being able to sort it as I wish, I want to select customer debt between 60 and 120 days and sort by total. The code is like this:
SELECT
SUM(cod_fat_cli) "Total",
nom_cad_cli "Nome",
end_cad_cli "Endereço"
FROM
cadastro_cliente
WHERE
--Seleciona as faturas em aberto
cod_fat_cli = 'AB'
--Seleciona as faturas vencidas entre 60 e 120 dias
AND venc_fat_cli BETWEEN trunc(sysdate -120) AND trunc(sysdate - 60)
Doubt
If I order by cod_fat_cli returns ordering the largest invoices, but I need the largest sums.
I think your SQL is wrong the field
cod_fat_cli
is to be summed and is as string filter.– Tiedt Tech