MySQL语句,使用replace替换数据后,有小数时,使用round等方法无法取整

15.55这个数字

replace替换数据后乘以100,在Navicat中运行,是显示整数

但是在Python中调用SQL语句,使用replace替换数据并乘以100后,会显示有一位小数,并且使用round等方法无法取整

最终采用cast函数将replace后的数字转成整数

CAST(value as type)

CAST(value as SIGNED),将数据转成整数,SIGNED代表整数

select CAST(REPLACE(uld.to_am,'-','')*100 AS SIGNED)
                           from transfer_arrears as ta
                           LEFT JOIN(
                           select apply_sn,user_id,sum(amount) as to_am
                           from user_loan_detail
                           WHERE type=4
                           GROUP BY user_id) as uld on ta.sn=uld.apply_sn
                           WHERE ta.work_flow_status=4 and uld.to_am <> ''

在Python中运行后,数据显示1555,没有小数点,成功取整

最近更新

  1. TCP协议是安全的吗?

    2024-04-28 17:50:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-28 17:50:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-28 17:50:02       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-28 17:50:02       20 阅读

热门阅读

  1. ssh -t 命令使用

    2024-04-28 17:50:02       14 阅读
  2. SSH ControlMaster功能

    2024-04-28 17:50:02       11 阅读
  3. 在ubuntu20上编译bcc时遇到:Could NOT find LibDebuginfod

    2024-04-28 17:50:02       11 阅读
  4. mysql数据库开发军规

    2024-04-28 17:50:02       13 阅读
  5. 朱元璋逆袭史:从流浪行僧到大明雄主

    2024-04-28 17:50:02       13 阅读
  6. Nest.js项目初始配置

    2024-04-28 17:50:02       15 阅读
  7. Redis(四) 主从、哨兵、集群环境搭建

    2024-04-28 17:50:02       12 阅读
  8. 【spring mvc】配置请求到视图名称转换器

    2024-04-28 17:50:02       10 阅读
  9. 机器学习之K-medians聚类

    2024-04-28 17:50:02       11 阅读