四舍五入函数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,MIN、COUNT、SUM为聚合函数
SELECT AVG(goods_price) AS avg_price FROM tdb_goods;
SELECT ROUND(avg_price,2) AS avg_price FROM tdb_goods;

四舍五入函数ROUND(x,y)的更多相关文章

  1. MySQL四舍五入函数ROUND(x)、ROUND(x,y)和TRUNCATE(x,y)

    MySQL四舍五入函数ROUND(x) ROUND(x)函数返回最接近于参数x的整数,对x值进行四舍五入. 实例: 使用ROUND(x)函数对操作数进行四舍五入操作.SQL语句如下: mysql> ...

  2. c++四舍五入函数round()

    其实c++自身是没有四舍五入函数round()的,若果你要用到的话,可以自己写一个round(),不过要用到floor()和ceil这两个函数如下: #include<iostream> ...

  3. oracle函数 round(x[,y])

    [功能]返回四舍五入后的值 [参数]x,y,数字型表达式,如果y不为整数则截取y整数部分,如果y>0则四舍五入为y位小数,如果y小于0则四舍五入到小数点向左第y位. [返回]数字 [示例] se ...

  4. mysql系列四、mySQL四舍五入函数用法总结

    一.MySQL四舍五入函数ROUND(x) ROUND(x)函数返回最接近于参数x的整数,对x值进行四舍五入. 实例: 使用ROUND(x)函数对操作数进行四舍五入操作.SQL语句如下: mysql& ...

  5. php四舍五入函数(floor、ceil、round与intval)

    原文链接:php四舍五入函数(floor.ceil.round与intval) PHP(外文名: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言.语法 ...

  6. 改写python round()函数,解决四舍五入问题 round(1.365,2)=1.36

    round()函数四舍五入存在一个问题,遇到5不一定进一.如下图所示: print(round(1.365,2)) #1.36 没进一 print('%.2f'%1.365) print(round( ...

  7. Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明

    Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明 FLOOR——对给定的数字取整数位SQL> select floor(2345.67) from dua ...

  8. 问题:oracle floor;结果:Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明

    Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明 (2011-04-06 16:10:35) 转载▼ 标签: 谈 分类: 渐行渐远 FLOOR——对给定的数字取 ...

  9. Javascript四舍五入(Math.round()与Math.pow())

    代码 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ ...

随机推荐

  1. Ubuntu 16.4 安装anaconda 详细教程

    下载 官方下载地址:https://www.continuum.io/downloads 所有安装包地址:https://repo.continuum.io/archive/ 这里使用 Python ...

  2. 使用super调用父类的构造方法

    package com.bjpowernode.t02inheritance.c09; /* * 使用super调用父类的构造方法 */public class TestSuper02 { publi ...

  3. pika的阻塞式使用

    [root@cloudplatform ELK]# cat startIncHouTai.py import os # 杀掉内存中的进程 cmd='pgrep -f PutDataToKafkaInc ...

  4. hdu 1711( 模式串T在主串S中首次出现的位置)

    Sample Input213 51 2 1 2 3 1 2 3 1 3 2 1 21 2 3 1 313 51 2 1 2 3 1 2 3 1 3 2 1 21 2 3 2 1 Sample Out ...

  5. centos7 编译安装php 5.6

    https://www.cnblogs.com/37yan/p/6879404.html

  6. [转]ubuntu安装skype

    Skype 4.3 Released, How to Install it in Ubuntu 14.04/12.04 June 19, 2014 — 107 Comments   Skype for ...

  7. linux下设置php执行命令

    第一种方法: 打开用户根目录下的: vi ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bash ...

  8. P3719 [AHOI2017初中组]rexp

    P3719 [AHOI2017初中组]rexp一开始想的是类似计算式子的值的东西,用栈.然后发现处理最大值很麻烦,因为处理的很像子过程,所以考虑递归来做.碰到'('就递归一次,碰到'|'就取最大值再递 ...

  9. Java开发人员必须掌握的Linux命令(三)

    做一个积极的人 编码.改bug.提升自己 我有一个乐园,面向编程,春暖花开! 学习应该是快乐的,在这个乐园中我努力让自己能用简洁易懂(搞笑有趣)的表达来讲解知识或者技术,让学习之旅充满乐趣,这就是写博 ...

  10. Spring 自动定时任务配置

    Spring中可以通过配置方便的实现周期性定时任务管理,这需要用到以下几个类: org.springframework.scheduling.quartz.MethodInvokingJobDetai ...