From 233897cc35771710739fd829ebc18942899e8133 Mon Sep 17 00:00:00 2001 From: PavelBegunkov <asml.Silence@gmail.com> Date: Tue, 26 Aug 2014 15:52:49 +0400 Subject: [PATCH] sort --- db/StoredProcedures.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql index b74c31c81..1efdc5e9f 100644 --- a/db/StoredProcedures.sql +++ b/db/StoredProcedures.sql @@ -1064,8 +1064,10 @@ BEGIN study_groups.ID = disciplines_groups.StudyGroupID LEFT JOIN `disciplines_students` ON DisciplineID = disciplines_students.DisciplineID AND students.ID = disciplines_students.StudentID - WHERE disciplines_students.Type = 'attach' OR - disciplines_groups.StudyGroupID IS NOT NULL; + WHERE disciplines_groups.StudyGroupID IS NOT NULL OR + disciplines_students.StudentID IS NOT NULL + ORDER BY study_groups.Grade ASC, study_groups.GroupNum; + ELSE SELECT NULL AS 'StudentID', NULL AS 'LastName', @@ -1336,7 +1338,8 @@ BEGIN WHERE disciplines_students.Type = 'attach' OR ( ( disciplines_students.Type IS NULL OR disciplines_students.Type != 'detach' ) AND disciplines_groups.StudyGroupID IS NOT NULL - ); + ) + ORDER BY study_groups.Grade ASC, study_groups.GroupNum ASC; ELSE SELECT NULL AS 'StudentID', NULL AS 'LastName', -- GitLab