-- 字符函数:
-- 查询结果姓名小写
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. C、C++基础和编程风格 (转)

    原文链接 作者:寒小阳时间:2013年8月.出处:http://blog.csdn.net/han_xiaoyang/article/details/10515417.声明:版权所有,转载请注明出处, ...

  2. 数据输入——生成你需要的echart图(堆积柱状图、扇形图、嵌套环形图)

    最近论文需要一些比较直观的图表, 发现echart做出来的图还是比较美观的,这里介绍如何修改数据生成你需要的echart图. 1.堆积柱状图: http://echarts.baidu.com/exa ...

  3. Vue-router的基本使用

    Vue-router的基本使用 相关Html: <!DOCTYPE html> <html lang="en"> <head> <meta ...

  4. puppet的使用:puppet配置文件介绍

    配置文件的产生 Puppet安装完后,配置文件就产生了,名称为puppet.conf,一般在/etc/puppet路径下. master也可以通过命令: puppet master --genconf ...

  5. python基础笔记之面向对象

    # class Foo:# name="kevin"## def __init__(self,puppy):# self.tomato= 'red'# self.dog = pup ...

  6. PHP 修改目录下所有与文件夹重名的前缀文件为index.后缀

    <?phpset_time_limit(0); function traverse($path = '.' , $dir_name='') { $current_dir = opendir($p ...

  7. Jmeter环境搭建

    一.工具描述 Apache JMeter是 100 %的 java 桌面应用程序.它可以被用来测试包括基于静态和动态资源程序的性能,例如静态文件, Java Servlets , Java  对象,数 ...

  8. 可视化的Redis数据库管理工具redis-desktop-manager的初步使用(图文详解)

    不多说,直接上干货! 无论是Linux 还是 Windows里安装Redis, Windows里如何正确安装Redis以服务运行(博主推荐)(图文详解) Windows下如何正确下载并安装可视化的Re ...

  9. leetcode 98,判断二叉树为BST

    方法一,记录子树的上界和下界,root的左子树一定小于root的值,root的右子树一定大于root的值,然后递归左子树和右子树 public class Solution { public bool ...

  10. 面试题21:如何判断二叉树是搜索二叉树BST?

    Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as ...