oracle学习记录2
-- case的使用
select last_name,
department_id,
salary,
case department_id
when 10 then salary * 1.1
when 20 then salary * 1.2
when 30 then salary * 1.3
end new_sal
from employees
where department_id in (10, 20, 30);
--decode使用
select last_name,
department_id,
salary,
decode(department_id, 10, salary * 1.1,
20, salary * 1.2,
30, salary * 1.3
) new_sal
from employees
where department_id in (10, 20, 30);
--字符串拼接
select *
from employees
where last_name like '%\_%' escape '\';
-- nvl 使用
select last_name, salary * 12 * (1 + nvl(commission_pct, 0)) year_sal
from employees;
--to_char的使用
select to_char(sysdate,'yyyy-mm-dd')
from dual;
努力学习java的Cherish