-- 字符函数:
-- 查询结果姓名小写
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. RabbitMQ和Kafka对比以及场景使用说明

    我目前的项目最后使用的是RabbitMQ,这里依然是结合网上大神们的优秀博客,对kafka和rabbitmq进行简单的比对.最后附上参考博客. 1.架构模型 rabbitmq RabbitMQ遵循AM ...

  2. java的Arrays工具类

    1年多了,jdk还不是很熟,补补. package lhy.core.util; import java.util.Arrays; import java.util.List; public clas ...

  3. 【数组】Sort Colors

    题目: Given an array with n objects colored red, white or blue, sort them so that objects of the same ...

  4. Java_反射机制详解

    本篇文章依旧采用小例子来说明,因为我始终觉的,案例驱动是最好的,要不然只看理论的话,看了也不懂,不过建议大家在看完文章之后,在回过头去看看理论,会有更好的理解. 下面开始正文. [案例1]通过一个对象 ...

  5. Python的Django框架中forms表单类的使用方法详解

    用户表单是Web端的一项基本功能,大而全的Django框架中自然带有现成的基础form对象,本文就Python的Django框架中forms表单类的使用方法详解. Form表单的功能 自动生成HTML ...

  6. 使用vue2+Axios+Router 之后的总结以及遇到的一些坑

    构建 vue有自己的脚手架构建工具vue-cli,使用起来非常方便,使用webpack来集成各种开发便捷工具,比如: 代码热更新,修改代码之后网页无刷新改变,对前端开发来说非常的方便 PostCss, ...

  7. Ripple(瑞波币)validator-keys-tool 配置验证器

    目录 Ripple(瑞波币)validator-keys-tool配置验证器 验证器密钥工具指南 验证器密钥 验证器令牌(Validator Keys) public_key撤销 签名 Ripple( ...

  8. XRP节点部署

    目录 XRP节点部署 准备 硬软件配置(建议) 安装Rippled服务 一. 以Stock Server模型运行 在何种情况下运行此模式 二 .以 Validator模式运行 在何种情况下运行此模式 ...

  9. javaScript中用eval()方法转换json对象

    var u = eval('('+user+')'); 1.对于服务器返回的JSON字符串,如果jQuery异步请求没做类型说明,或者以字符串方式接受,那么需要做一次对象化处理,方式不是太麻烦,就是将 ...

  10. 使用docker-compose 部署服务 上

    转自:https://www.cnblogs.com/neptunemoon/p/6512121.html 使用docker-compose 大杀器来部署服务 上 使用docker-compose 大 ...