Rabu, 09 November 2011

Basis Data Modul 8 (Query)

select max (salary), min(salary), sum(salary), round(avg(salary))
from employees;

select job_id, max (salary), min(salary), sum(salary), round(avg(salary))
from employees
group by job_id;

select job_id, count(last_name)
from employees
group by job_id;

select count(DISTINCT(manager_id))"Jumlah Manager"
from employees;

select max (salary)- min (salary) "Perbedaan Gaji"
from employees;

select manager_id, min (salary)
from employees
group by manager_id
having min(salary)>6000
order by min(salary)asc;

select count(employee_id)"total",
sum(decode(to_char(hire_date , 'yyyy'),1995,1,0)) "1995",
sum(decode(to_char(hire_date , 'yyyy'),1996,1,0)) "1996",
sum(decode(to_char(hire_date , 'yyyy'),1997,1,0)) "1997",
sum(decode(to_char(hire_date , 'yyyy'),1998,1,0)) "1998"
from employees
where to_char (hire_date, 'yyyy') in('1995','1996','1997','1998');

select job_id,
nvl (to_char(sum(decode(department_id ,20, salary))),' ') "Dept 20",
nvl (to_char(sum(decode(department_id ,50, salary))),' ') "Dept 50",
nvl (to_char(sum(decode(department_id ,80, salary))),' ') "Dept 80",
nvl (to_char(sum(decode(department_id ,90, salary))),' ') "Dept 90",
sum(salary)"Total"
from employees
group by job_id
order by job_id asc;

Tidak ada komentar:

Posting Komentar