문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top