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
67 lines (49 loc) · 1.72 KB
/
answers.sh
File metadata and controls
67 lines (49 loc) · 1.72 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
1. select name from students ;
2. select * from students
where age > 30 ;
3.select name from students
where gender = "F" and age = 30 ; # there is no female of age 30, there is only above 30 (age > 30)
4.select points from students
where name = "Alex" ;
5.INSERT INTO students ( Name, Age, Gender, Points)
VALUES('Kamal', 28, 'M', 400) ;
6.UPDATE students
SET points = 400
WHERE
name = "Basma" ;
7.update students
set points = 350
where
name = "Alex" ;
CREATE TABLE "graduates" (
"ID" INTEGER NOT NULL UNIQUE,
"Name" TEXT NOT NULL UNIQUE,
"Age" INTEGER,
"Gender" TEXT,
"Points" INTEGER,
"Graduation" TEXT,
PRIMARY KEY("ID" AUTOINCREMENT)
);
10. insert into graduates (id, name, age, gender, points) select id, name, age, gender, points from students
where name = "Layal" ;
11. update graduates
set graduation = "08/09/2018" ; # didn't add a condition sice there is only one row
12.delete from students
where name = "Layal" ;
14.select employees.name, employees.role, employees.company, companies.date from employees
join companies on employees.company = companies.name ;
15.select name from (select employees.name, employees.role, employees.company, companies.date from employees
join companies on employees.company = companies.name )
where date < 2000 ;
16.select company from (select employees.name, employees.role, employees.company, companies.date from employees
join companies on employees.company = companies.name )
where role = "Graphic Designer" ;
18.select name from students
where points = (select max(points) from students) ;
19.select avg(points) from students ;
20.select count(name) from students
where points = 500 ;
21.select name from students
where name like "%s%" ;
22.select name from students
order by points desc ;