Advertisement
Teammasik

Laba_4_DB

Mar 31st, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.78 KB | None | 0 0
  1. --1)
  2. SELECT COUNT(Student_Id) as 'students'
  3. FROM Exam_mark
  4. WHERE Subj_Id = 2
  5.  
  6. --2)
  7. SELECT COUNT(DISTINCT Subj_Id) as 'Количество дисциплин'
  8. FROM Exam_mark;
  9.  
  10. --3)
  11. SELECT Student_Id, MIN(Mark) as 'Мин оценка'
  12. FROM Exam_mark
  13. GROUP BY Student_Id;
  14.  
  15. --4)
  16. SELECT Student_Id, MAX(Mark) as 'Макс оценка'
  17. FROM Exam_mark
  18. GROUP BY Student_Id;
  19.  
  20. --5)
  21. SELECT Subj_Id, MIN(Mark) as 'Мин оценка'
  22. FROM Exam_mark
  23. GROUP BY Subj_Id;
  24.  
  25. --6)
  26. SELECT Exam_Date, COUNT(Student_Id) as 'Кол-во студентов'
  27. FROM Exam_mark
  28. GROUP BY Exam_Date;
  29.  
  30. --7)
  31. SELECT Subj_Id, AVG(Mark) as 'Средний балл'
  32. FROM Exam_mark
  33. GROUP BY Subj_Id
  34.  
  35. --8)
  36. SELECT Student_Id, AVG(Mark) as 'Средний балл'
  37. FROM Exam_mark
  38. GROUP BY Student_Id
  39.  
  40. --9)
  41. SELECT COUNT(DISTINCT Subj_Id) as 'Кол-во дисциплин'
  42. FROM Exam_mark
  43. WHERE Mark>4
  44.  
  45. ------------------------------------------------------------------
  46. --1)*
  47. SELECT Student_id, Surname, Stipendia,(Stipendia*120)/100 AS 'Стипендия +20%'
  48. FROM Student
  49. ORDER BY Stipendia, Surname
  50.  
  51. --2)
  52. SELECT TOP (2) Surname
  53. FROM Student WHERE Surname like %'
  54. ORDER BY Surname
  55.  
  56. --3)
  57. SELECT Student_id, max(Mark) as 'Макс. оценка' , min(Mark) as 'Мин. оценка'
  58. FROM Exam_mark
  59. GROUP BY Student_Id
  60.  
  61. --4)*
  62. SELECT Subj_Name, Hour
  63. FROM Subject
  64. ORDER BY Subj_Name DESC, hour asc
  65.  
  66. --5)
  67. SELECT Exam_Date, Sum(Mark) as 'Сумма баллов'
  68. FROM Exam_mark
  69. GROUP BY Exam_Date
  70. ORDER BY Sum(Mark) DESC
  71.  
  72. --6)*
  73. SELECT AVG(Mark) as 'Средняя оценка',MIN(Mark) as 'Минимальная оценка',MAX(Mark) as 'Максимальная оценка', Exam_Date
  74. FROM Exam_mark
  75. GROUP BY Exam_Date
  76. ORDER BY 1 DESC, 2 desc, 3 desc
  77.  
  78.  
  79.  
  80.  
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement