Skip to content
Snippets Groups Projects
Commit 9afa1f29 authored by PavelBegunkov's avatar PavelBegunkov
Browse files

REF: sql, still alive

parent 8fe30595
Branches
Tags
No related merge requests found
This diff is collapsed.
CREATE OR REPLACE VIEW `view_study_groups` AS CREATE OR REPLACE VIEW `view_study_groups` AS
SELECT study_groups.ID AS 'GroupID', SELECT study_groups.ID AS 'GroupID',
study_groups.GroupNum AS 'GroupNum', study_groups.GroupNum AS 'GroupNum',
...@@ -17,9 +20,6 @@ CREATE OR REPLACE VIEW `view_study_groups` AS ...@@ -17,9 +20,6 @@ CREATE OR REPLACE VIEW `view_study_groups` AS
INNER JOIN `faculties` ON faculties.ID = specializations.FacultyID; INNER JOIN `faculties` ON faculties.ID = specializations.FacultyID;
CREATE OR REPLACE VIEW `view_teachers` AS CREATE OR REPLACE VIEW `view_teachers` AS
SELECT teachers.ID AS 'TeacherID', SELECT teachers.ID AS 'TeacherID',
teachers.LastName, teachers.LastName,
...@@ -75,6 +75,16 @@ CREATE OR REPLACE VIEW `view_disciplines` AS ...@@ -75,6 +75,16 @@ CREATE OR REPLACE VIEW `view_disciplines` AS
INNER JOIN `grades` ON grades.ID = disciplines.GradeID; INNER JOIN `grades` ON grades.ID = disciplines.GradeID;
CREATE OR REPLACE VIEW `view_disciplines_results` AS
SELECT modules.DisciplineID,
SUM(submodules.MaxRate) AS 'DisciplineRateMax',
SUM(submodules.MaxRate*submodules.isUsed) AS 'DisciplineRateCur'
FROM `submodules`
INNER JOIN `modules` ON modules.ID = submodules.ModuleID
WHERE (modules.Type = 'regular') OR (modules.Type = 'exam' AND submodules.OrderNum = 1)
GROUP BY modules.DisciplineID;
CREATE OR REPLACE VIEW `view_disciplines_teachers` AS CREATE OR REPLACE VIEW `view_disciplines_teachers` AS
SELECT view_disciplines.DisciplineID, SELECT view_disciplines.DisciplineID,
view_teachers.*, view_teachers.*,
...@@ -85,13 +95,14 @@ CREATE OR REPLACE VIEW `view_disciplines_teachers` AS ...@@ -85,13 +95,14 @@ CREATE OR REPLACE VIEW `view_disciplines_teachers` AS
CREATE OR REPLACE VIEW `view_disciplines_students` AS CREATE OR REPLACE VIEW `view_disciplines_students` AS
SELECT disciplines_students.DisciplineID, SELECT disciplines_students.DisciplineID,
disciplines_students.Type AS 'AttachType',
view_students.* view_students.*
FROM `disciplines_students` FROM `disciplines_students`
INNER JOIN `view_students` ON view_students.StudentID = disciplines_students.StudentID INNER JOIN `view_students` ON view_students.StudentID = disciplines_students.StudentID
WHERE disciplines_students.Type = 'attach'
UNION DISTINCT UNION DISTINCT
SELECT disciplines_groups.DisciplineID, SELECT disciplines_groups.DisciplineID,
NULL AS 'AttachType',
view_students.* view_students.*
FROM `disciplines_groups` FROM `disciplines_groups`
LEFT JOIN `view_students` ON view_students.GroupID = disciplines_groups.StudyGroupID LEFT JOIN `view_students` ON view_students.GroupID = disciplines_groups.StudyGroupID
...@@ -145,3 +156,4 @@ CREATE OR REPLACE VIEW `view_rating_result` AS ...@@ -145,3 +156,4 @@ CREATE OR REPLACE VIEW `view_rating_result` AS
WHERE view_rating.Rate IS NOT NULL WHERE view_rating.Rate IS NOT NULL
GROUP BY view_rating.StudentID, view_rating.DisciplineID; GROUP BY view_rating.StudentID, view_rating.DisciplineID;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment