Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Using TO_CHAR With Subtraction and AVG Function
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
![]() |
![]() |