Untitled

                Never    
SQL
       
1.select s.kodsali
from sala s, zajecia z, wykladowca w, ocena o
where z.id_sala=s.id_sala and
      z.id_wykladowca=w.id_wykladowca and
      o.id_zajecia=z.id_zajecia and
      o.data = (select min(o.data) 
                from ocena o);

2.select distinct dzientyg from zajecia z, przedmiot p, ocena o
where z.id_przedmiot=p.id_przedmiot and
      o.id_zajecia=z.id_zajecia and
      p.id_przedmiot in (select p.id_przedmiot 
                         from przedmiot p, ocena o, zajecia z
                         where z.id_przedmiot=p.id_przedmiot and
                         o.id_zajecia=z.id_zajecia
                         group by p.id_przedmiot
                         having count(o.id_ocena) = (select max(count(id_ocena)) from ocena o, przedmiot p, zajecia z
                                                    where z.id_przedmiot=p.id_przedmiot and
                                                    o.id_zajecia=z.id_zajecia
                                                    group by p.id_przedmiot))
3.select distinct k.nazwa 
from kierunek k, student s, grupa g, zajecia z, charakter ch
where k.id_kierunek=g.id_kierunek and
      s.id_grupa=g.id_grupa and
      g.id_grupa=z.id_grupa and
      ch.id_charakter=z.id_charakter and
      s.id_student in (select s.id_student 
                       from student s, grupa g, zajecia z, charakter ch
                       where s.id_grupa=g.id_grupa and
                       g.id_grupa=z.id_grupa and
                       ch.id_charakter=z.id_charakter and
                       ch.nazwa like 'Laboratoria'
                       group by s.id_student
                       having count(z.id_zajecia) > (select avg(count(z.id_zajecia))
                                                     from zajecia z, charakter ch
                                                     where ch.id_charakter=z.id_charakter and
                                                     ch.nazwa like 'Laboratoria'
                                                     group by ch.id_charakter))

4.select distinct w.imie, w.nazwisko 
from wykladowca w, budynek b, zajecia z, sala s
where w.id_wykladowca=z.id_wykladowca and
      b.id_budynek=s.id_budynek and
      z.id_sala=s.id_sala and 
      b.id_budynek in (select b.id_budynek
                       from budynek b, sala s
                       where b.id_budynek=s.id_budynek and
                       s.id_sala = (select max(s.id_sala) from sala s))

5.select distinct g.nazwa 
from grupa g, przedmiot p, zajecia z, student s
where s.id_grupa=g.id_grupa and
      p.id_przedmiot=z.id_przedmiot and
      g.id_grupa=z.id_grupa and
      p.id_przedmiot in (select p.id_przedmiot
                         from przedmiot p, student s, grupa g, zajecia z
                         where s.id_grupa=g.id_grupa and
                         p.id_przedmiot=z.id_przedmiot and
                         g.id_grupa=z.id_grupa 
                         group by p.id_przedmiot
                         having count(s.id_student) = (select min(count(s.id_student))
                                                       from przedmiot p, student s, grupa g, zajecia z
                                                       where s.id_grupa=g.id_grupa and
                                                       p.id_przedmiot=z.id_przedmiot and
                                                       g.id_grupa=z.id_grupa 
                                                       group by p.id_przedmiot))

6.select distinct p.nazwa, count(s.id_student) ile
from przedmiot p, zajecia z, student s, grupa g, kierunek k
where s.id_grupa=g.id_grupa and
      p.id_przedmiot=z.id_przedmiot and
      g.id_grupa=z.id_grupa and
      g.id_kierunek=k.id_kierunek
      group by p.nazwa
      having count(s.id_student) > (select avg(count(s.id_student))
                                  from student s, kierunek k, grupa g
                                  where s.id_grupa=g.id_grupa and
                                  g.id_kierunek=k.id_kierunek
                                  group by k.id_kierunek)
     order by ile desc

Raw Text