forked from NWC2/SQL-Exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswers.sh
More file actions
76 lines (52 loc) · 1.55 KB
/
answers.sh
File metadata and controls
76 lines (52 loc) · 1.55 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
1-SELECT name from students
2-SELECT * FROM students WHERE Age>30
3-SELECT name FROM students WHERE Gender ='F' AND Age=30
4-SELECT Points FROM students WHERE name="Alex"
5-INSERT INTO students(name,Age,Gender,Points) VALUES('ali',24,'M',1000)
6-UPDATE students
SET Points =Points+100
WHERE name ="Basma"
7-UPDATE students
SET Points =Points-10
WHERE name ="Alex"
Part-2 Create a table
CREATE TABLE "graduates" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL UNIQUE,
"age" INTEGER,
"gender" TEXT,
"points" INTEGER,
"graduation" TEXT
);
10-INSERT INTO graduates (name, age, gender,points)
SELECT name, age, gender,points
FROM students
WHERE students.Name='Layal';
11-UPDATE graduates
SET graduation ="08/09/2018"
WHERE name ="Layal"
12-DELETE FROM students WHERE students.Name="Layal"
//JOIN Part
14-CREATE TABLE Result AS
SELECT employees.Name as employee_name,
companies.Name as company_name,
companies.Date as company_date
FROM employees
INNER JOIN companies
ON employees.Company = companies.Name
15-SELECT employee_name FROM Result WHERE company_date<2000
16-SELECT Company FROM employees WHERE Role="Graphic Designer"
18-SELECT students.Name
FROM students
WHERE Points = (SELECT MAX(Points) FROM students);
19-SELECT avg(points)
FROM students
20-SELECT count(students.Name)
FROM students
WHERE Points=500
21-SELECT students.Name
FROM students
WHERE students.Name like "%s%"
22-SELECT *
FROM students
ORDER by Points DESC