zoukankan      html  css  js  c++  java
  • 四舍五入函数ROUND(x,y)

    四舍五入函数ROUND(x,y)
    参数: x:数据 y:需要保留的小数点位数
    ROUND(x,y)函数返回最接近于参数x的数,其值保留到小数点后面y位,若y为负值,则将保留x值到小数点左边y位。 mysql> select round(32.154,2); +-----------------+ | round(32.154,2) | +-----------------+ | 32.15 | +-----------------+ 1 row in set (0.41 sec) mysql> select round(32.154,1); +-----------------+ | round(32.154,1) | +-----------------+ | 32.2 | +-----------------+ 1 row in set (0.02 sec) mysql> select round(32.154,0); +-----------------+ | round(32.154,0) | +-----------------+ | 32 | +-----------------+ 1 row in set (0.00 sec) mysql> select round(32.154,3); +-----------------+ | round(32.154,3) | +-----------------+ | 32.154 | +-----------------+ 1 row in set (0.00 sec) mysql> 求所有电脑产品的平均价格,并且保留两位小数,AVG,MAX,MINCOUNT、SUM为聚合函数
    SELECT AVG(goods_price) AS avg_price FROM tdb_goods;
    SELECT ROUND(avg_price,2) AS avg_price FROM tdb_goods;
  • 相关阅读:
    Python 模块管理
    Python 练习: 计算器
    Linux 系统性能分析工具 sar
    Python 正则介绍
    Python ConfigParser 模块
    Python logging 模块
    Python hashlib 模块
    Python sys 模块
    09 下拉框 数据验证
    08 条件排序
  • 原文地址:https://www.cnblogs.com/dengyg200891/p/6029379.html
Copyright © 2011-2022 走看看