Sum function causing poor performance
Need help rewriting this query, it is taking hours to execute.
With Complex_query as ( Select product_name, credit, adjust, receipts… contains 412k records)
Select sum(credit), sum(adjust), sum(receipts ), program_name, transaction_number
from (select (select trx_Date) from dual where trx_number = transaction_number)invoice_date, receipts, credit, adjust
from complex_query)
Group by program_name, invoice_date
order by program_name, transaction_number;