排序和单行函数

排序

select * from emp order by sal desc; -- 工资倒序
select * from emp order by sal ;   --默认正序
select * from emp order by sal desc,hiredate desc; --工资和入职日期倒序
select *from emp;

 

单行函数

select  1 from dual;  --dual是伪表
select upper('smith') from dual;    --把小写字符转换为大写字符
select lower('SMITH') from dual;   --把大写字符转换为小写字符

select initcap('smith') from dual;    --把首字母转换为大写

 select concat('hello','world') from dual;  --把hello和world连接起来
 
select  'hello' | |  'world' from dual;     --同上   建议使用,可以跨平台
select substr('hello',1,4) from dual;   --切割字符串

select length('hello') from dual; --计算字符串的长度
select replace('hello','l', 'x') from dual;  --替换字符串中的字符把  ll  替换成  xx  

select round(13.89) from dual; --四舍五入  等于14

select round(13.5678,3)from dual; --保留 3 位小数

select trunc(12.89) from dual; --去掉小数部分,不进行四舍五入  结果是12

select trunc(12.3465, 2) from dual; --只留下两位小数    不进行四舍五入结果是12.34


select mod(11,3)from dual;--取余数 结果是2
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值