问题
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.
来源:https://stackoverflow.com/questions/9696496/decimal-formatting-in-sql-query