我想添加常数6位和2位小数, 我有以下价值观:
1500.000
1.000
766898.930
如何将这些数字转换为
001500.00
000001.00
766898.93
我使用了这些代码,但没有任何效果:
SELECT REPLACE (STR(REPLACE(cast (MonthlyPayment.LocalAmount AS NUMERIC(18,2) ) ,'.',''),9),' ',0) FROM MonthlyPayment
SELECT REPLACE (cast(cast(MonthlyPayment.LocalAmount AS NUMERIC(18,2) ) AS NCHAR(9)),' ',0) FROM MonthlyPayment
请,帮助
答案 0 :(得分:2)
str()
函数表明您正在使用SQL Server。
SELECT right(replicate('0', 9) + cast(cast(MonthlyPayment.LocalAmount AS NUMERIC(9, 2) ) as varchar(10)), 9)
FROM MonthlyPayment;
以下是步骤:
答案 1 :(得分:0)
如果2012+尝试格式化功能
$posts = Post::where( .... );
$posts->paginate(20, ['ID', 'title', \DB::raw('LEFT(body, 200) AS body')], ....);