-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent's Major
More file actions
56 lines (46 loc) · 1.19 KB
/
Student's Major
File metadata and controls
56 lines (46 loc) · 1.19 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Student's Major
A university maintains data on students and their majors in three tables: STUDENTS, MAJORS, and REGISTER. The university needs a list of the STUDENT_NAME and MAJOR_NAME of the first 20 students. Do not sort the list.
Table Schema
STUDENTS
Name Type Description
STUDENT_ID Integer The ID of a student. This is the primary key.
STUDENT_NAME String The name of the student.
STUDENT_AGE Integer The age of the student.
MAJORS
Name Type Description
MAJOR_ID Integer The ID of a major. This is the primary key.
MAJOR_NAME String
The name of a major.
REGISTER
Name Type Description
STUDENT_ID Integer The ID of a student. This is a foreign key.
MAJOR_ID Integer The ID of a major. This is a foreign key.'
Sample Case 0
Sample Input 0
STUDENTS
STUDENT_ID STUDENT_NAME STUDENT_AGE
1 John 20
2 Masie 21
3 Harry 21
MAJORS
MAJOR_ID MAJOR_NAME
1000 Computer Science
2000 Biology
3000 Physics
REGISTER
STUDENT_ID MAJOR_ID
2 1000
3 3000
1 2000
Sample Output
John Biology
Masie Computer Science
Harry Physics
//CODE
SELECT students.student_name, majors.major_name
FROM students
JOIN register
ON students.student_id = register.student_id
JOIN majors
ON register.major_id = majors.major_id
LIMIT 20;