Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Using TO_CHAR With Subtraction and AVG Function
<ITAnnaJones_at_gmail.com> a écrit dans le message de news: 1166504708.311640.279470_at_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) over (partition by inv_number), '$99,999.99') AS "AVG INVOICE
AMT",
TO_CHAR((LINE_UNITS*LINE_PRICE) - (AVG(LINE_UNITS*LINE_PRICE) over (partition by inv_number)),
'$99,999.99') AS "DIFF"
FROM LINE
/
Regards
Michel Cadot
Received on Tue Dec 19 2006 - 00:52:30 CST