You are on page 1of 2

--ex1

select id_angajat,nume,salariul,id_functie,
salariul* decode(id_functie,'SA_MAN',1.1,'SA_REP',1.05,1.01) salariu_majorat,
decode(id_functie,'SA_MAN','10%','SA_REP','5%','1%') procent
from angajati;

--ex2
select id_angajat,nume,salariul,id_functie,
case id_functie when 'SA_MAN' then 1.1
when 'SA_REP' then 1.05
else 1.1
end sal_majorat
from angajati;

select id_angajat,nume,salariul,comision,
case
when salariul>10000 then 'venituri mari'
when comision is not null then 'venituri medii'
else 'venituri mici' end clasificare_venituri
from angajati;

select id_angajat, salariul, level, case level


when 1 then 0.3 when 2 then 0.15 else 0.02 end spor_conducere
from angajati
connect by prior id_angajat = id_manager
start with id_angajat=100;

--ex4
select a.id_departament, d.denumire_departament, count(id_angajat),
case when count(id_angajat)>30 then 1
when count (id_angajat) between 20 and 30 then 2
when count (id_angajat) between 6 and 20 then 3
else 4 end top
from angajati a, departamente d
where a.id_departament=d.id_departament
group by a.id_departament,d.denumire_departament
order by 4;

update angajati
set salariul = salariul*decode(id_functie, 'SA_MAN',1.1,'SA_REP',1.05,1.01);

select case when id_functie in ('SA_MAN','SA_REP') then 'Sales'


when id_functie like '%IT%' then 'IT'
else 'Alti_ang' end categorie,
sum(case when id_functie in ('SA_MAN','SA_REP') then salariul
when id_functie like '%IT' then salariul
else salariul end) suma_salarii
from angajati
group by case when id_functie in ('SA_MAN','SA_REP') then 'Sales'
when id_functie like '%IT%' then 'IT'
else 'Alti_ang' end;

select case when extract (month from data) in (12, 1, 2) then 'iarna'
when extract(month from data) between 3 and 5 then 'primavara'
when extract(month from data) between 6 and 8 then 'vara'
else 'toamna' end anotimpuri,
sum (case when extract (month from data) in (12, 1,2) then pret*cantitate
when extract(month from data) between 3 and 5 then pret*cantitate
when extract(month from data) between 6 and 8 then pret*cantitate
else pret*cantitate end) suma_vanzari
from comenzi c, rand_comenzi r
where c.nr_comanda=r.nr_comanda
group by case when extract (month from data) in (12, 1, 2) then 'iarna'
when extract(month from data) between 3 and 5 then 'primavara'
when extract(month from data) between 6 and 8 then 'vara'
else 'toamna' end
order by 2;

select id_departament,round( a.nr_ang_dep*100/b.nr_ang_tot,2) "% mr ang",


round(a.sal_ang_dep*100/b.sal_ang_tot,2) "% sal ang"
from
(select id_departament, count (id_angajat) nr_ang_dep, sum(salariul) sal_ang_dep
from angajati group by id_departament) a,
(select count(id_angajat) nr_ang_tot, sum(salariul) sal_ang_tot
from angajati) b;

You might also like