Question

I am guessing this is a straight forward task but just cannot seem to get this to work. I want to add to column values together and then format the result in Oracle SQL. So i thought i could do something like:

to_char(INVOICE_NET, '9,999,999.99') + to_char(INVOICE_TAX, '9,999,999.99')  AS GROSS_PRICE

This fails as i guess these are no longer numbers Then i thought this may work:

INVOICE_NET + INVOICE_TAX AS to_char(GROSS_PRICE, '9,999,999.99')

This also fails. Can anyone put me straight please on this.

Was it helpful?

Solution

Why not indeed :) Thank you , I was hoping it was something straight forward. I added nvl() functions to the net and tax columns.

So now looks like this:

to_char(nvl(INVOICE_NET,0) + nvl(INVOICE_TAX,0), '9,999,999.99') AS GROSS_PRICE 

many thanks for your help wxyz

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top