Fakultet

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

-- 1.

select ime || ' ' || prezime


from student
where extract(year from sysdate) - 2 = extract(year from datumupisa)
and status = 'budzet'
order by brojindeksa desc;

-- 2.
select *
from smer
where fakultetid in (select fakultetid
from fakultet
where grad = 'Novi Sad')
and fakultetid in (select fakultetid
from smer
where brojsemestara > 8);

-- 3.
select s.brojindeksa, sm.nazivsmera
from student s join smer sm on (s.smerid = sm.smerid)
join fakultet f on (s.fakultetid = f.fakultetid and sm.fakultetid = f.fakultetid)
where s.datumupisa + interval '2' year < '10-JUL-2019';

-- 4.
select p.predmetid, sum(case when po.ocena > 5 then 1 else 0 end) as polozilo
from predmet p join polaganje po on (p.predmetid = po.predmetid)
group by p.predmetid
having avg(po.brojpoena) < 70;

-- 5.
select sm.fakultetid, sm.nivostudija,
sum(case when s.status = 'budzet' then 1 else 0 end) as broj_budzet
from smer sm join student s on (sm.smerid = s.smerid)
join fakultet f on (sm.fakultetid = f.fakultetid and s.fakultetid = f.fakultetid)
where f.godinaosnivanja > 1965
group by sm.fakultetid, sm.nivostudija;

-- 6.
select ime, prezime, mestoprebivalista
from student
where brojindeksa in (select brojindeksa
from polaganje
group by brojindeksa
having avg(ocena) in (select min(avg(ocena))
from polaganje
group by brojindeksa));

-- 7.
select f.fakultetid, sm.smerid, sm.nazivsmera, sm.nivostudija,
max(s.datumupisa) as prvi_student
from smer sm join student s on (sm.smerid = s.smerid)
join fakultet f on (f.fakultetid = sm.fakultetid and f.fakultetid = s.fakultetid)
where sm.fakultetid in (select fakultetid
from fakultet
where fakultetid in (select fakultetid
from smer
group by fakultetid
having count(smerid) > 1))
and (sm.fakultetid, sm.smerid) in (select fakultetid, smerid
from student
group by fakultetid, smerid
having count(*) < (select max(count(*))
from student
where fakultetid =
sm.fakultetid
group by fakultetid,
smerid))
group by f.fakultetid, sm.smerid, sm.nazivsmera, sm.nivostudija
order by sm.smerid asc;

You might also like