mysql小数转换整数_MySQL:将小数转换为百分比

I've inherited a database and am using views in MySQL to return specific information from a database. I'm having a little trouble one portion- turning the returned numeric value that is a decimal into a percentage.

I don't want to do this in the php- I am specifically trying to format everything in the view first. I realize this is not necessarily the way everyone does this, but for my specific situation it is the best overall solution.

The example value in the database: 0.46

What I'd like to have returned: 46%

Relevant portions of current query:

SELECT CONCAT(a.fa_rate, '%') as rate_percent

FROM accounts a;

This returns 0.46%. Is it possible to return the result I want to have without converting the number into a string? The current data type is a float.

解决方案

try this

SELECT CONCAT(a.fa_rate * 100 , '%') as rate_percent

FROM accounts a;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值