--1 --select distinct naziv --from da.predmet p join da.ispit i on p.id=i.idpredmeta --where indeks=20170022 and status not in ('p', 'n'); --select naziv --from da.predmet --where id in (select idpredmeta -- from da.ispit -- where indeks=20170022 and status not in ('p', 'n')) ; --select naziv --from da.predmet --where 20170022 in (select indeks -- from da.ispit -- where idpredmeta=id and status not in ('p', 'n') ); --2 --select ime, prezime --from da.dosije d --where 9 in (select ocena -- from da.ispit i -- where d.indeks=i.indeks -- and status='o'); --select distinct d.indeks, ime, prezime --from da.dosije d join da.ispit i -- on d.indeks=i.indeks -- and status='o' and ocena=9; --3 --select distinct indeks --from da.ispit --where ocena>5 and status='o' -- and idpredmeta not in (select idpredmeta -- from da.ispit -- where ocena>5 and status='o' -- and indeks=20170022); --4 --select naziv --from da.predmet --where exists (select * -- from da.ispit -- where idpredmeta= id and ocena>5 -- and status='o' and indeks=20170022); --5 --select * --from da.predmet p --where not exists (select * -- from da.SKOLSKAGODINA sg -- where not exists (select * -- from da.kurs k -- where k.idpredmeta=p.id -- and sg.skgodina=k.skgodina)); --6 --select * --from da.dosije d --where not exists ( select * -- from da.SKOLSKAGODINA sg -- where not exists (select * -- from da.UPISGODINE ug -- where ug.indeks=d.indeks -- and ug.skgodina=sg.skgodina)); --7 --select indeks --from da.dosije d --where not exists ( select * -- from da.ispitnirok ir -- where not exists ( select * -- from da.ispit i -- where i.indeks=d.indeks -- and i.skgodina =ir.skgodina -- and ir.oznakaroka=i.oznakaroka -- and status not in ('p', 'n'))); --8 --select indeks --from da.dosije d --where not exists ( select * -- from da.ispitnirok ir -- where skgodina=2018 -- and not exists ( select * -- from da.ispit i -- where i.indeks=d.indeks -- and i.skgodina =ir.skgodina -- and ir.oznakaroka=i.oznakaroka -- and status not in ('p', 'n'))); --9 --select * --from da.predmet --where espb >= all ( select espb -- from da.predmet); --10 --select * --from da.dosije --where datdiplomiranja <= all (select datdiplomiranja -- from da.dosije -- where datdiplomiranja is not null); --11 --izdvajanje samo studenata koji imaju datum diplomiranja --select * --from da.dosije --where not datdiplomiranja <= all (select datdiplomiranja -- from da.dosije -- where datdiplomiranja is not null) --order by indeks; --izdvajanje svih osim studenata sa najranijim datumom diplomiranja --select * --from da.dosije --where not datdiplomiranja <= all (select datdiplomiranja -- from da.dosije -- where datdiplomiranja is not null) -- or datdiplomiranja is null --order by indeks; --select * --from da.dosije --where datdiplomiranja > some (select datdiplomiranja -- from da.dosije -- where datdiplomiranja is not null) -- or datdiplomiranja is null --order by indeks; --select * --from da.dosije d1 --where exists (select datdiplomiranja -- from da.dosije d2 -- where d1.datdiplomiranja > d2.datdiplomiranja) -- or datdiplomiranja is null --order by indeks; -- 12 --select * --from da.predmet --where id = any (select idpredmeta -- from da.UPISANKURS); --select * --from da.predmet --where id in (select idpredmeta -- from da.UPISANKURS); --select * --from da.predmet --where exists (select idpredmeta -- from da.UPISANKURS -- where id=idpredmeta); --13 --select ime, prezime, naziv, skgodina, oznakaroka, ocena --from da.dosije d left join da.ispit i -- on d.indeks=i.indeks and ocena>5 and status='o' -- left join da.predmet p -- on i.idpredmeta=p.id --where exists (select * -- from da.ispit -- where indeks=d.indeks and skgodina=2018 -- and status not in ('p', 'n')); --14 --select * --from da.predmet p --where not exists (select * -- from da.dosije d join da.studijskiprogram s -- on d.idprograma=s.id -- where mestorodjenja='Berane' and s.oznaka='I' -- and not exists (select * -- from da.ispit i -- where i.indeks=d.indeks -- and i.idpredmeta=p.id -- and status not in ('p', 'n') ));