Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Базы Данных Лабораторная 3

.docx
Скачиваний:
10
Добавлен:
18.02.2017
Размер:
16.32 Кб
Скачать

Лабораторная работа №3

1)

SELECT s.Name

FROM Student s

WHERE s.Surname = 'Ryazantseva'

2)

SELECT StudentID, Name, Surname

FROM Student

ORDER BY Surname DESC

3)

SELECT DepartmentID, DepName

FROM Department

WHERE FoundationDate > '18900101'

ORDER BY DepartmentID

4)

SELECT LearningGroup.GroupName, Name, Surname

FROM LearningGroup

INNER JOIN Student ON LearningGroup.GroupID = Student.GroupID

5)

SELECT s.Name + ' ' + s.Surname AS StudentName, lg.GroupName, sp.SpecName

FROM Student AS s

JOIN LearningGroup AS lg ON s.GroupID = lg.GroupID

LEFT JOIN Speciality AS sp ON lg.SpecialityID = sp.SpecialityID

6)

SELECT COUNT(s.StudentID) AS NumberOfStudents, sp.SpecName, lg.GroupName

FROM Student AS s

JOIN LearningGroup AS lg ON s.GroupID = lg.GroupID

JOIN Speciality AS sp ON lg.SpecialityID = sp.SpecialityID

GROUP BY sp.SpecName, lg.GroupName

7)

SELECT COUNT(s.StudentID) NumberOfStudents, sp.SpecName, lg.GroupName

FROM Student s

JOIN LearningGroup lg ON s.GroupID = lg.GroupID

JOIN Speciality sp ON lg.SpecialityID = sp.SpecialityID

GROUP BY sp.SpecName, lg.GroupName

ORDER BY NumberOfStudents

8)

SELECT COUNT(c.CourseName), lg.GroupName

FROM Course c

JOIN Speciality sp ON c.SpecialityID = sp.SpecialityID

JOIN LearningGroup lg ON sp.SpecialityID = lg.SpecialityID

GROUP BY lg.GroupName

HAVING COUNT(c.CourseName) > 1

9)

SELECT dep.DepName, sp.SpecName, c.CourseName

FROM Department dep

JOIN Speciality sp ON dep.DepartmentID = sp.DepartmentID

JOIN Course c ON sp.SpecialityID = c.SpecialityID

WHERE c.CourseName = 'C++ Programming'

10)

SELECT sp.SpecName

FROM Speciality sp

JOIN LearningGroup lg ON sp.SpecialityID = lg.SpecialityID

WHERE lg.FormOfLearning = 'Full-time'

11)

SELECT dep.DepName, s.Surname + ' ' + s.Name + ' ' + s.Patronymic FullName, lg.GroupName

FROM Department dep

JOIN Speciality sp ON dep.DepartmentID = sp.DepartmentID

JOIN LearningGroup lg ON sp.SpecialityID = lg.SpecialityID

JOIN Student s ON lg.GroupID = s.GroupID

WHERE s.Name = 'Ruslan'

12)

SELECT COUNT(lg.FormOfLearning) SumFullTime

FROM LearningGroup lg

WHERE lg.FormOfLearning = 'Full-time'

13)

SELECT lg.GroupName, lg.GroupID

FROM Speciality sp

LEFT JOIN LearningGroup lg ON sp.SpecialityID = lg.SpecialityID

WHERE sp.SpecName = 'Ancient History'

14)

SELECT c.CourseName, sp.SpecName

FROM Course c

JOIN Speciality sp ON c.SpecialityID = sp.SpecialityID

WHERE sp.DepartmentID = 3

15)

SELECT c.CourseName, sp.SpecName, dep.DepName, dep.FoundationDate DepFoundationDate

FROM Course c

JOIN Speciality sp ON c.SpecialityID = sp.SpecialityID

JOIN Department dep ON sp.DepartmentID = dep.DepartmentID

WHERE c.CourseName = 'C# Programming'