-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTAKKULA_datbase.sql
More file actions
56 lines (56 loc) · 1.7 KB
/
TAKKULA_datbase.sql
File metadata and controls
56 lines (56 loc) · 1.7 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
-- 1.1
SELECT * FROM Campus
-- 1.2
SELECT city, campus_name FROM Campus
ORDER BY city ASC, campus_name ASC;
-- 1.3
SELECT sanction_code, description, decision_maker FROM SanctionType
ORDER BY sanction_code DESC;
-- 1.4
SELECT description FROM MisconductType
ORDER BY description ASC;
-- 1.5
SELECT surname, first_name, teacher_number FROM Teacher
ORDER BY surname, first_name, teacher_number ASC;
-- 1.6
SELECT student_number, surname, first_name, birth_date, gender FROM Student
WHERE gender = 'F'
ORDER BY student_number ASC;
-- 1.7
SELECT salary, surname, first_name, teacher_number FROM Teacher
WHERE salary > 16000
ORDER BY salary DESC;
-- 1.8
SELECT teacher_number FROM Teacher
WHERE first_name = 'Veera' AND surname = 'Vainio';
-- 1.9
SELECT examiner, course_code, instance_number, student_number,
grade FROM CourseGrade
WHERE examiner = 'h784'
ORDER BY course_code, instance_number, student_number ASC;
-- 1.10
SELECT start_date, end_date, course_code, instance_number FROM CourseInstance
WHERE YEAR (start_date) = 2007 AND YEAR (end_date) = 2007
ORDER BY start_date, end_date, course_code, instance_number ASC;
-- 1.11
SELECT gender, birth_date, surname, first_name FROM Student
WHERE surname BETWEEN 'A' AND 'K'
ORDER BY
CASE WHEN gender = 'M' THEN 0
WHEN gender = 'F' THEN 1
ELSE 2
END,
birth_date ASC;
-- 1.13
SELECT table_name
FROM information_schema.tables
ORDER BY table_name
-- 1.14
SELECT table_name, column_name, data_type, character_maximum_length,
numeric_precision, numeric_scale, is_nullable
FROM information_schema.columns
WHERE table_name = 'Teacher'
-- 1.15
SELECT table_catalog, table_name, constraint_name, constraint_type
FROM information_schema.table_constraints
ORDER BY table_name, constraint_name