SQL query to get AP spend by each country to determine top 5 countries
I am trying to run a query to get payables spend by each country/set of books for my customer in order to determine top 5 countries.
The challenge I am running into is that each set of books/country has invoices in different currencies(foreign currency invoices)
How do I arrive a total number to compare across set of books
This is the query I was using but obviously it doesn't include any logic to handle currency or currency conversions
SELECT SUM(APIA.amount_PAID) Amount , APIA.set_of_books_id,apia.invoice_currency_code
FROM APPS.ap_invoice_payments_all API,