SQL Language (MOSC)

MOSC Banner

summing in a subquery

edited Sep 18, 2010 5:06AM in SQL Language (MOSC) 3 commentsAnswered ✓
 Hello All,
I have a subquery I want to sum a value.  I am unsure on how to accomplish it in a subquery.  Below I have two fields, one being needed to tie to the main query (invoice_id) and the other I want summed(paid_to_supplier).  Since the id field is unique to each line ,how do I get the sum?

select inv.invoice_id
          ,NVL (sum (DECODE (inv.invoice_currency_code,'USD', inv.amount_paid,(inv.amount_paid * inv.exchange_rate))), inv.amount_paid) paid_to_supplier
 from ap_invoices_all inv
          ,ap_invoice_distributions_all apd2

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center