I need to make a report and I can not sort it as a wish, I want to select customer debit between 60 and 120 days and sort by total. The code looks 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 by ordering the larger invoices, but I need the larger sums.