Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Using TO_CHAR With Subtraction and AVG Function

Using TO_CHAR With Subtraction and AVG Function

From: <ITAnnaJones_at_gmail.com>
Date: 18 Dec 2006 21:07:51 -0800
Message-ID: <1166504871.550287.286090@73g2000cwn.googlegroups.com>


I am trying to show a list of invoice numbers, with each invoice total formatted as currency, then the average of all of the invoices formatted as currency, then the diff between the two formatted as currency. Below is what I have so far, but I cannot get it to work! Any assistance is appreciated.

Thanks!

SELECT INV_NUMBER,
  TO_CHAR(LINE_UNITS*LINE_PRICE,'$99,999.99') AS "INVOICE TOTAL",   TO_CHAR(AVG(LINE_UNITS*LINE_PRICE), '$99,999.99') AS "AVG INVOICE AMT",
  TO_CHAR((LINE_UNITS*LINE_PRICE) - (AVG(LINE_UNITS*LINE_PRICE)), '$99,999.99') AS "DIFF"
 FROM LINE
 GROUP BY INV_NUMBER Received on Mon Dec 18 2006 - 23:07:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US