sql 字符串函数、数学函数
-- 字符函数:
-- 查询结果姓名小写
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 字符串函数、数学函数的更多相关文章
- javascript函数一共可分为五类: ·常规函数 ·数组函数 ·日期函数 ·数学函数 ·字符串函数
javascript函数一共可分为五类: ·常规函数 ·数组函数 ·日期函数 ·数学函数 ·字符串函数 1.常规函数 javascript常规函数包括以下9个 ...
- Delphi 常用函数(数学函数)round、trunc、ceil和floor
源:Delphi 常用函数(数学函数)round.trunc.ceil和floor Delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里 ...
- php常用函数——数学函数
php常用函数——数学函数
- sql server 系统常用函数:聚合函数 数学函数 字符串函数 日期和时间函数和自定义函数
一.系统函数 1.聚合函数 聚合函数常用于GROUP BY子句,在SQL Server 2008提供的所有聚合函数中,除了COUNT函数以外,聚合函数都会忽略空值AVG.COUNT.COUNT_BIG ...
- SQL server 数据库——数学函数、字符串函数、转换函数、时间日期函数
数学函数.字符串函数.转换函数.时间日期函数 1.数学函数 ceiling()--取上限 select ceiling(oil) as 油耗上限 from car floor()--取下限 sele ...
- MySQL 进阶4 SQL常见函数: 字符函数/数学函数/日期函数/流程控制函数(if/case)
# 进阶4 SQL常见函数 分类: 1/单行函数: 字符函数: concat(),length(),ifnull(__,default) ,instr(), trim(),upper(),lower( ...
- SQL 字符串分割表函数
--字符串分割表函数 ) ) declare @i int; declare @count int; ); ); declare @Index int; )) declare @rowID int; ...
- MySql常用函数数学函数、加密函数等(转—收藏)
MySql函数众多,这里只是列举了一部分常用的函数. 一.数学函数 ABS(x) // 返回x的绝对值 BI ...
- VB.NET函数——数学函数/字母串函数
一.数学函数 函数 说明 Abs (num) 取绝对值. Exp (num) 返回以e为底.以num为指数的值,如Exp(2)返回e^2值. Log (num) 返回参数num的自然对数值,为Doub ...
- ios开发函数(数学函数应用)
今天在计算collectionView存放最小间距的时候用到一函数 " ABS " 顺便就查了一下这些数学函数在代码中的使用.. //----------------------- ...
随机推荐
- CPM(Cluster Percolation method)派系过滤算法
一.概念 (1)完全子图/全耦合网络/k-派系:所有节点全部两两相连 图1 这些全耦合网络也成为派系,k-派系表示该全耦合网络的节点数目为k 1)k-派系相邻:两个不同的k-派系共享k-1个节点,认为 ...
- h5聊天室web端(仿微博、微信)|h5仿微信网页端|仿微信界面弹窗
这段时间一直在着手h5开发手机端聊天系统——html5仿微信聊天室,最近又在原先基础上开发了一个仿微信.微博网页web版聊天系统,使用到了HTML5+css3+jQuery+wcpop等技术开发,弹窗 ...
- 【SQL查询】树结构查询
格式:SELECT ... FROM + 表名 WHERE + 条件3 START WITH + 条件1 CONNECT BY PRIOR + 条件2条件1: 表示从哪个节点开始查找, 也就是通过条件 ...
- Spring Boot的Servlet简单使用
当使用spring-Boot时,嵌入式Servlet容器通过扫描注解的方式注册Servlet.Filter和Servlet规范的所有监听器(如HttpSessionListener监听器). Spri ...
- python 把一文件包含中文的字符写到另外文件乱码 UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position
报错的代码是: file2 = open('target.txt','w')for line in open('test.txt'): file2.write(line)原因:文件编码不一致导致解决方 ...
- linux 编译安装amqp
背景: 下面的内容是我根据网上博客小松的文章 https://www.phpsong.com/2223.html 做的修改,因为我走到make 编译amqp这步报错 最开始报下面的这个错误,是因为要安 ...
- Python -- Gui编程 -- MFC的使用
1.消息框 mfcDialog.py import win32ui import win32con from pywin.mfc import dialog class MyDialog(dialog ...
- tensorflow model save and restore
TensorFlow 模型保存/载入 我们在上线使用一个算法模型的时候,首先必须将已经训练好的模型保存下来.tensorflow保存模型的方式与sklearn不太一样,sklearn很直接,一个skl ...
- Python中文分词 jieba
三种分词模式与一个参数 以下代码主要来自于jieba的github,你可以在github下载该源码 import jieba seg_list = jieba.cut("我来到北京清华大学& ...
- freepbx对接gms网关
前面的文章阿里云使用镜像安装freepbx , 安装freepbx后创建sip分机 ,freepbx的SIP通话客户端X-lite Yate eyeBeam Linphone我们已经成功的创建好了分机 ...