Advertisement
bazmikel

Untitled

Apr 3rd, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.00 KB | None | 0 0
  1.  
  2. -- zad 1
  3. select nr_indeksu,nazwisko,imiona,data_urodzenia,adres,kierunek from studenci where data_urodzenia = (select min(data_urodzenia) from studenci where kierunek like 'INF%');
  4.  
  5.  
  6.  
  7. -- zad 3
  8. select waga, gatunki.nazwa,lowiska.nazwa as lowisko,nazwisko,imiona as imie, To_char (czas, 'yy/dd/mm') as rok
  9. from rejestry join wedkarze using (id_wedkarza) join lowiska using(id_lowiska) left join gatunki using(id_gatunku)
  10. 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)
  11. and trim(To_char(czas,'mm'))=5 group by trim(To_char(czas,'month')));
  12.  
  13.  
  14. -- zad 5
  15. select kierunek, srednia, nazwisko, imiona, nr_indeksu, stopien, rok, tryb  
  16. from studenci where ((kierunek, srednia) in (select kierunek, max(srednia)      
  17. from studenci where imiona like '%a' group by kierunek ) or (kierunek, srednia) in (select kierunek, max(srednia)      
  18. from studenci where imiona not like '%a' group by kierunek)) order by kierunek, srednia desc, tryb;
  19.  
  20. -- zad 10
  21. select
  22.     NVL((SELECT nazwa from gatunki where id_gatunku=d1.id_gatunku),'BRAK POLOWU') nazwa_gatunku,
  23.     To_Char(czas, 'YYYY-MM-DD') || ' ' || To_char(czas, 'HH:MM') as Ostatni_Polow,
  24.     Extract(DAY from sysdate - czas) as Dni,
  25.     (SELECT nazwisko from wedkarze where id_wedkarza=d1.id_wedkarza) nazwisko_wedkarza,
  26.     (SELECT nazwa from lowiska where id_lowiska=d1.id_lowiska) nazwa_lowiska
  27. from rejestry d1
  28. where czas = (SELECT max(czas) from rejestry where id_gatunku=d1.id_gatunku)
  29. or czas = (SELECT max(czas) from rejestry where id_gatunku is null)
  30. order by Dni desc;
  31.  
  32. -- zad 11
  33. select nvl(ga.nazwa, 'brak polowu') nazwa,
  34. czas, extract(day from (systimestamp-czas)) dni,
  35. nazwisko,
  36. lo.nazwa
  37. from rejestry full join gatunki ga using (id_gatunku)
  38. full join wedkarze using (id_wedkarza) full join lowiska lo using (id_lowiska)
  39. where (nvl(id_gatunku,0), decode(czas, null, 'brak', czas)) in (select nvl(id_gatunku,0), decode(max(czas), null, 'brak', max(czas))      
  40. from rejestry full join gatunki using (id_gatunku) group by id_gatunku) order by 1;
  41.  
  42.  
  43. --zad 12
  44. 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
  45. (select id_dzialu, max(data_zatr) from pracownicy where data_zwol is null or data_zwol>sysdate group by id_dzialu)
  46. or (id_dzialu, data_zatr) in
  47. (select id_dzialu, min(data_zatr) from pracownicy where data_zwol is null or data_zwol>sysdate group by id_dzialu);
  48.  
  49.  
  50.  
  51. -- zad 14
  52. select * from(
  53. select Ulica, count(Ulica) Liczba_Wystapien  from
  54. (select trim(substr(adres, 5 ,REGEXP_INSTR(substr(adres, 5), '\ [[:digit:]]{1,3}'))) as Ulica from studenci)
  55. group by Ulica
  56. order by 2 desc)
  57. where rownum = 1;
  58.  
  59.  
  60. -- zad 16
  61. select * from(
  62. select id_okregu, id_lowiska, nazwa, sum(waga) Laczna_waga, count(*) Liczba_Polowow, count(id_gatunku) Liczba_Ryb
  63. from rejestry re join lowiska lo using(id_lowiska)
  64. group by id_okregu, id_lowiska, nazwa
  65. order by 4 desc
  66. )
  67. where id_okregu like 'PZW%'`;
  68.  
  69.  
  70. -- zad 17
  71. select tryb, stopien, kierunek, rok, count(*) as liczb_studentow
  72. from studenci
  73. group by grouping sets((tryb, stopien, kierunek, rok), (tryb, stopien, kierunek), (tryb, stopien), (tryb))
  74. order by 1,2,3,4;
  75.  
  76. -- zad 18
  77. 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,
  78. tryb, stopien, kierunek, rok, count(*)as liczb_studentow
  79. from studenci
  80. group by grouping sets((tryb, stopien, kierunek, rok), (tryb, stopien, kierunek), (tryb, stopien), (tryb), ())
  81. order by 2,3,4,5;
  82.  
  83.  
  84.  
  85. -- zad 19
  86. select wlasciciel, id_wlasciciela, typ, marka, count(*)
  87. from pojazdy po join wlasciciele we using(id_wlasciciela)
  88. group by grouping sets((wlasciciel, id_wlasciciela, typ, marka), (wlasciciel, id_wlasciciela, typ), (wlasciciel, id_wlasciciela), typ, marka, ())
  89. having count(*) >=3
  90. order by 5 desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement