Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- zad 1
- select nr_indeksu,nazwisko,imiona,data_urodzenia,adres,kierunek from studenci where data_urodzenia = (select min(data_urodzenia) from studenci where kierunek like 'INF%');
- -- zad 3
- select waga, gatunki.nazwa,lowiska.nazwa as lowisko,nazwisko,imiona as imie, To_char (czas, 'yy/dd/mm') as rok
- from rejestry join wedkarze using (id_wedkarza) join lowiska using(id_lowiska) left join gatunki using(id_gatunku)
- where(trim(To_char(czas,'month')),waga) in (select trim(To_char(czas,'month'))miesiac,NVL(max(waga),0) from rejestry where (trim(To_char(czas,'d'))=6 or trim(To_char(czas,'d'))=7)
- and trim(To_char(czas,'mm'))=5 group by trim(To_char(czas,'month')));
- -- zad 5
- select kierunek, srednia, nazwisko, imiona, nr_indeksu, stopien, rok, tryb
- from studenci where ((kierunek, srednia) in (select kierunek, max(srednia)
- from studenci where imiona like '%a' group by kierunek ) or (kierunek, srednia) in (select kierunek, max(srednia)
- from studenci where imiona not like '%a' group by kierunek)) order by kierunek, srednia desc, tryb;
- -- zad 10
- select
- NVL((SELECT nazwa from gatunki where id_gatunku=d1.id_gatunku),'BRAK POLOWU') nazwa_gatunku,
- To_Char(czas, 'YYYY-MM-DD') || ' ' || To_char(czas, 'HH:MM') as Ostatni_Polow,
- Extract(DAY from sysdate - czas) as Dni,
- (SELECT nazwisko from wedkarze where id_wedkarza=d1.id_wedkarza) nazwisko_wedkarza,
- (SELECT nazwa from lowiska where id_lowiska=d1.id_lowiska) nazwa_lowiska
- from rejestry d1
- where czas = (SELECT max(czas) from rejestry where id_gatunku=d1.id_gatunku)
- or czas = (SELECT max(czas) from rejestry where id_gatunku is null)
- order by Dni desc;
- -- zad 11
- select nvl(ga.nazwa, 'brak polowu') nazwa,
- czas, extract(day from (systimestamp-czas)) dni,
- nazwisko,
- lo.nazwa
- from rejestry full join gatunki ga using (id_gatunku)
- full join wedkarze using (id_wedkarza) full join lowiska lo using (id_lowiska)
- where (nvl(id_gatunku,0), decode(czas, null, 'brak', czas)) in (select nvl(id_gatunku,0), decode(max(czas), null, 'brak', max(czas))
- from rejestry full join gatunki using (id_gatunku) group by id_gatunku) order by 1;
- --zad 12
- select id_dzialu, dzialy.nazwa, nazwisko, nr_akt, data_zatr, data_zwol from pracownicy join dzialy using (id_dzialu) where (id_dzialu, data_zatr) in
- (select id_dzialu, max(data_zatr) from pracownicy where data_zwol is null or data_zwol>sysdate group by id_dzialu)
- or (id_dzialu, data_zatr) in
- (select id_dzialu, min(data_zatr) from pracownicy where data_zwol is null or data_zwol>sysdate group by id_dzialu);
- -- zad 14
- select * from(
- select Ulica, count(Ulica) Liczba_Wystapien from
- (select trim(substr(adres, 5 ,REGEXP_INSTR(substr(adres, 5), '\ [[:digit:]]{1,3}'))) as Ulica from studenci)
- group by Ulica
- order by 2 desc)
- where rownum = 1;
- -- zad 16
- select * from(
- select id_okregu, id_lowiska, nazwa, sum(waga) Laczna_waga, count(*) Liczba_Polowow, count(id_gatunku) Liczba_Ryb
- from rejestry re join lowiska lo using(id_lowiska)
- group by id_okregu, id_lowiska, nazwa
- order by 4 desc
- )
- where id_okregu like 'PZW%'`;
- -- zad 17
- select tryb, stopien, kierunek, rok, count(*) as liczb_studentow
- from studenci
- group by grouping sets((tryb, stopien, kierunek, rok), (tryb, stopien, kierunek), (tryb, stopien), (tryb))
- order by 1,2,3,4;
- -- zad 18
- select decode(grouping_id(tryb, stopien, kierunek, rok), 7, 'W danym trybie', 0, 'Na danym roku w TSK ', 1, 'Na danym Kierunku', 3, 'W ramach danego stopnia ', 15, 'Ogolem studiuje') as KOMENTARZ,
- tryb, stopien, kierunek, rok, count(*)as liczb_studentow
- from studenci
- group by grouping sets((tryb, stopien, kierunek, rok), (tryb, stopien, kierunek), (tryb, stopien), (tryb), ())
- order by 2,3,4,5;
- -- zad 19
- select wlasciciel, id_wlasciciela, typ, marka, count(*)
- from pojazdy po join wlasciciele we using(id_wlasciciela)
- group by grouping sets((wlasciciel, id_wlasciciela, typ, marka), (wlasciciel, id_wlasciciela, typ), (wlasciciel, id_wlasciciela), typ, marka, ())
- having count(*) >=3
- order by 5 desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement