-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestQueries.sql
More file actions
29 lines (21 loc) · 802 Bytes
/
TestQueries.sql
File metadata and controls
29 lines (21 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- uncomment these lines on first run
--USE courseDatabase;
--GO
-- Lists all students
SELECT * FROM students; -- Syntax: SELECT column1, column2, ... FROM table_name;
-- lists all teachers
select * from teachers;
-- lists all courses
select * from courses;
--lists all enrollments
select * from enrollments;
-- lists all courses taught by teacher with ID 100
select * from courses
where TeacherID = 100;
-- lists all courses that student with ID 1000 is enrolled in
select * from enrollments
where StudentID = 1000;
-- returns the number of courses that student with ID 1001 is enrolled in
select count(CourseID) from enrollments where StudentID = 1001;
-- lists all courses in order of credits, from least to greatest
select * from courses order by credits asc;