Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. --7
  2. select w.id_wlasciciela, w.wlasciciel, w.adres,
  3. count(p.nr_rejestracyjny) as "Liczba_pojazdow",
  4. (select max(count(nr_rejestracyjny))
  5. from pojazdy where typ in ('SAM_OSOBOWY') and id_wlasciciela=id_wlasciciela
  6. group by id_wlasciciela) as "Osobowe",
  7. (select max(count(nr_rejestracyjny))
  8. from pojazdy where typ in ('MOTOCYKL') and id_wlasciciela=id_wlasciciela
  9. group by id_wlasciciela) as "Motocykle"
  10. from wlasciciele w, pojazdy p where w.id_wlasciciela=p.id_wlasciciela
  11. and p.typ in ('SAM_OSOBOWY', 'MOTOCYKL')
  12. group by w.id_wlasciciela, w.wlasciciel, w.adres
  13. having count(nr_rejestracyjny)=(select max(count(nr_rejestracyjny))
  14. from pojazdy where typ in ('SAM_OSOBOWY', 'MOTOCYKL')group by id_wlasciciela)
  15. order by 1;
  16.  
  17. --8
  18. select * from oceny;
  19. select * from studenci;
  20. select s.nr_indeksu, s.nazwisko, s.imiona, s.kierunek, s.rok,
  21. (select max(count(nr_indeksu))from oceny where ocena = 5 group by nr_indeksu )as "Liczba ocen 5"
  22. from studenci s, oceny o;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement