decimal formatting in sql query

2019-08-31 22:23发布

问题:

I have a query as below:

Select price from myTable;

This returns value '22.50'

However, I need the format as 5.8 bytes in my program.

That is my String value should be '00022.50000000' and not '22.50'

Is there a way to achieve this directly in SQL ?

回答1:

From docs, I think you want CHAR( DECIMAL( 22.50, 13, 8 ) )

I have no DB2 instance to play with so can't verify. These functions are not ANSI SQL, they are DB2 specific.



标签: sql db2