Beruflich Dokumente
Kultur Dokumente
ees;
select employee_id, last_name, salary, NVL2(commission_pct,commission_pct,'1111'
) from employees;(to use nvl2)
select length(first_name),length(last_name) from employees;
select length(first_name),length(last_name),nullif (length(first_name),length(la
st_name)) from employees;
select commission_pct,manager_id,salary, from employees;
select commission_pct,manager_id,salary,coalesce(commission_pct,manager_id,salar
y) as coal from employees; (to use for the checking the not null values)
CASE and decode
select salary, case(salary) when 10000 then 'c' when 12000 then 'b' when 24000 t
hen 'a' else 'd' end as grade from employees; (data type of all values must be s
ame in all conditions)
select salary, decode(salary,10000,'a',12000,'b',24000,'c','d') grade from emplo
yees; ()
select salary, case when salary >= 10000 then 'A' when salary < 10000 then 'B' e
lse 'C' end as grade from employees; (using the condition in the case using iden
tifier with values)
================================================
chapter 4 ()
================================================
select department_id, sum(salary) from employees group by department_id order by
department_id;
select department_id,job_id , sum(salary),count(*) from employees group by depar
tment_id, job_id order by department_id;
select department_id, sum(salary) from employees group by department_id having s
um(salary)>10000 order by 1;
--------------rollup (extensation of group by ) (display n and n+1)
--------------select department_id,job_id, sum(salary) from employees group by rollup (departm
ent_id,job_id) order by department_id;
--------------cube ()
--------------select department_id,job_id, sum(salary) from employees group by cube(department
_id,job_id) order by department_id;
========================
chepter 5 displaying
========================
1) cartesion (select * from regions, countries)
2) selection
3) projection
select employee_id, last_name, salary, e.department_id, department_name from emp
loyees e, departments d where e.department_id = d.department_id
select employee_id, last_name, salary, e.department_id, department_name from emp
name='Abel');
select * from employees where department_id = (select department_id from employe
es where employee_id=104) and employee_id <>104;
select * from employees where manager_id = (select manager_id from employees whe
re employee_id=118);
select * from employees where employee_id in (select manager_id from employees);
select * from employees where employee_id not in (select manager_id from employe
es where manager_id is not null);
(interview question)
select * from employees e, departments d where e.department_id(+) = d.department
_id(+)order by d.department_id;
ORA-01468: a predicate may reference only one outer-joined table