-- 字符函数:
-- 查询结果姓名小写
select lower(ename), sal, job from emp;
-- 查询结果姓名大写
select upper(ename), sal, job from emp;
-- 名字5个字符
select ename, sal, job from emp where length(ename)=5;
-- 名字前3个字符
select substr(ename, 1,3), sal, job from emp; -- 从第1个开始
select substr(ename, 2,3), sal, job from emp; -- 3-->取3个

-- 名字首字母大写
select upper(substr(ename, 1,1)) || lower(substr(ename, 2, length(ename)-1)) from emp;
select concat(upper(substr(ename, 1,1)), lower(substr(ename, 2, length(ename)-1))) from emp; -- mysql 要使用concat()函数
-- 名字首字母小写
select lower(substr(ename, 1,1)) || upper(substr(ename, 2, length(ename)-1)) from emp;
select concat(lower(substr(ename, 1,1)), upper(substr(ename, 2, length(ename)-1))) from emp; -- mysql 要使用concat()函数
-- 名字里的A替换为a
select replace(ename, 'A', 'a') ename from emp;

-- 数学函数:(这一部分 mysql 要把 nvl 替换为ifnull)
select ename, job, nvl(sal, 0)+ nvl(comm, 0) sal, dname from emp, dept where emp.deptno = dept.deptno and ename = 'SMITH';
select ename, job, nvl(sal, 0)+ nvl(comm, 0) sal, dname from emp join dept on emp.deptno = dept.deptno where ename = 'SMITH';
-- 一个月30天,日薪是多少
select ename, round(nvl(sal, 0)/30) from emp; -- 精确到整数
select ename, round(nvl(sal, 0)/30, 2) from emp; -- 精确到小数点后两位
select ename, round(nvl(sal, 0)/30, -1) from emp;-- 精确到十位

sql 字符串函数、数学函数的更多相关文章

  1. javascript函数一共可分为五类: ·常规函数 ·数组函数 ·日期函数 ·数学函数 ·字符串函数

    javascript函数一共可分为五类:    ·常规函数    ·数组函数    ·日期函数    ·数学函数    ·字符串函数    1.常规函数    javascript常规函数包括以下9个 ...

  2. Delphi 常用函数(数学函数)round、trunc、ceil和floor

    源:Delphi 常用函数(数学函数)round.trunc.ceil和floor Delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里 ...

  3. php常用函数——数学函数

    php常用函数——数学函数

  4. sql server 系统常用函数:聚合函数 数学函数 字符串函数 日期和时间函数和自定义函数

    一.系统函数 1.聚合函数 聚合函数常用于GROUP BY子句,在SQL Server 2008提供的所有聚合函数中,除了COUNT函数以外,聚合函数都会忽略空值AVG.COUNT.COUNT_BIG ...

  5. SQL server 数据库——数学函数、字符串函数、转换函数、时间日期函数

    数学函数.字符串函数.转换函数.时间日期函数 1.数学函数 ceiling()--取上限  select ceiling(oil) as 油耗上限 from car floor()--取下限 sele ...

  6. MySQL 进阶4 SQL常见函数: 字符函数/数学函数/日期函数/流程控制函数(if/case)

    # 进阶4 SQL常见函数 分类: 1/单行函数: 字符函数: concat(),length(),ifnull(__,default) ,instr(), trim(),upper(),lower( ...

  7. SQL 字符串分割表函数

    --字符串分割表函数 ) ) declare @i int; declare @count int; ); ); declare @Index int; )) declare @rowID int; ...

  8. MySql常用函数数学函数、加密函数等(转—收藏)

        MySql函数众多,这里只是列举了一部分常用的函数.   一.数学函数 ABS(x)                                         // 返回x的绝对值 BI ...

  9. VB.NET函数——数学函数/字母串函数

    一.数学函数 函数 说明 Abs (num) 取绝对值. Exp (num) 返回以e为底.以num为指数的值,如Exp(2)返回e^2值. Log (num) 返回参数num的自然对数值,为Doub ...

  10. ios开发函数(数学函数应用)

    今天在计算collectionView存放最小间距的时候用到一函数 " ABS " 顺便就查了一下这些数学函数在代码中的使用.. //----------------------- ...

随机推荐

  1. jmeter -- 在beanshell中拿到请求body参数和header参数

    beanshell: import org.apache.jmeter.config.Arguments; import org.apache.jmeter.protocol.http.control ...

  2. zabbix 调用python脚本监控 磁盘剩余空间(创建模版,创建监控项,创建触发器)

    主要 记录一下  使用zabbix 自己创建模版.监控项.触发器,并调用python脚本. 需求: 监控备份机磁盘剩余空间(windows系统) 一.安装zabbix_agent 比较简单 修改配置文 ...

  3. SQLServer2005重建索引

    今天发现一个页面运行很慢,用SQL Server Profiler抓出了一条运行时间为12s的sql ) and wfinstance is not null and wftbrq>='2016 ...

  4. 【数组】Search for a Range

    题目: Given a sorted array of integers, find the starting and ending position of a given target value. ...

  5. 如何虚拟机里安装Win10操作系统

    不多说,直接上干货! Windows Server 2003.2008.2012系统的安装 推荐网址:打开MSDN网站(http://msdn.itellyou.cn ) 关于给电脑换系统,很多人会花 ...

  6. 在Java Web项目中,不用ActionContext类来获得tomcat部署项目的绝对路径

    例子:sendIosApns.class.getClassLoader().getResource("").getFile().replaceAll("%20" ...

  7. HihoCoder - 1478 水陆距离

    水陆距离 描述 给定一个N x M的01矩阵,其中1表示陆地,0表示水域.对于每一个位置,求出它距离最近的水域的距离是多少. 矩阵中每个位置与它上下左右相邻的格子距离为1. 输入 第一行包含两个整数, ...

  8. Java封装Redis常用操作

    package com.advance.Redis; import org.apache.log4j.Logger; import org.testng.annotations.Test; impor ...

  9. 网络爬虫(一):配置selenium、pycharm(windows平台)

    最近在学习爬虫的编写,使用selenium模块时候,遇到了很多坑,本blog的目的是总结一下遇到的坑和解决办法,以便后来人少走弯路! 以下介绍均以Python3.x为基准进行,基于windows平台的 ...

  10. Shell脚本编写3---Shell 传递参数

    我们可以在执行 Shell 脚本时,向脚本传递参数,脚本内获取参数的格式为:$n.n 代表一个数字,1 为执行脚本的第一个参数,2 为执行脚本的第二个参数,以此类推…… 执行脚本,查看输出结果: 另外 ...