Subject MAX and SUM in the same query
Author radevojvodic
Hi All,

I have a table like this

ID, LEDGER_ID, PRICE, DEBIT, CREDIT, ITEM

I have to find Price where LEDGER_ID = MAX(LEDGER_ID) for each ITEM
and at the same time SUM(DEBIT), Sum(CREDIT) for that item. I have
tried to Join the table (lets name it journal) to itself and to use
having clause to get it to work. It does work but it's very slow. Is
there anyone that can help me to optimize the query.

Rade