Oracle(二)单行函数
select upper('yes') from dual;
select lower('YES') from dual;
select round(26.18) from dual;
select round(26.18,1) from dual;
select trunc(26.18) from dual;
select trunc(26.18,1) from dual;
select mod(10,3) from dual;
select sysdate-e.hiredate from emp e;
select sysdate+1 from dual;
select months_between(sysdate,e.hiredate) from emp e;
select months_between(sysdate,e.hiredate)/12 from emp e;
select (sysdate-e.hiredate)/7 from emp e;
select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual;
select to_char(sysdate,'fm yyyy-mm-dd hh:mi:ss') from dual;
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
select to_date('2020-11-03 10:57:23','yyyy-mm-dd hh:mi:ss') from dual;
select e.sal*12+nvl(e.comm,0) from emp e;
select e.ename,
case e.ename
when 'SMITH' then '曹贼'
when 'ALLEN' then '马贼'
when 'WARD' then '诸葛小儿'
else '无名小卒'
end 中文名
from emp e;
select e.sal,
case
when e.sal>3000 then '高收入'
when e.sal>1500 then '中等收入'
else '低收入'
end
from emp e;
select e.ename,
decode(
e.ename,
'SMITH', '曹贼',
'ALLEN', '马贼',
'WARD' , '诸葛小儿',
'无名小卒'
)"中文名"
from emp e;