Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. --------------------- ZAD1 ----------------------
  2. select substring(ime, 1, 1) + '.' + substring(prezime, 1, 1) + '.' as 'inicijali', year(datRod) as 'godina_rodjenja'
  3. from student;
  4.  
  5. select *
  6. from student
  7. order by datRod asc;
  8.  
  9. select top 1 ime, prezime
  10. from student
  11. where spol = 'F'
  12. order by datRod asc;
  13.  
  14. --------------------- ZAD2 ----------------------
  15. select count(mbr) as 'ukupno_studenata'
  16. from student;
  17.  
  18. select count(distinct pbrPreb) as 'razlicita mjesta prebivalista'
  19. from student;
  20.  
  21. --------------------- ZAD3 ----------------------
  22. select sifPredmeta, avg(cast(ocjena as float)) as 'prosjek predmeta'
  23. from ispit
  24. where ocjena > 1
  25. group by sifPredmeta;
  26.  
  27. --------------------- ZAD4 ----------------------
  28. select ime, prezime, avg(ocjena) as 'prosjek'
  29. from student, ispit
  30. where ocjena > 1 and mbrStud = mbr
  31. group by ime, prezime
  32. order by prosjek desc;
  33.  
  34. select mbrStud, avg(cast(ocjena as float)) as 'prosjek > 2.5'
  35. from ispit
  36. where ocjena > 1
  37. group by mbrStud
  38. having avg(ispit.ocjena) > 2.5
  39.  
  40. --------------------- ZAD5 ----------------------
  41. create view moj_pogled as
  42. select s.ime, s.prezime, p.naziv, i.mbrStud, i.datIspita, i.ocjena
  43. from student s, predmet p, ispit i
  44. where i.mbrStud = s.mbr and p.sifra = i.sifPredmeta;
  45.  
  46. select * from moj_pogled;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement