forked from Codi-T02/SQL-Exercise
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanswers.sh
More file actions
67 lines (48 loc) · 1.64 KB
/
answers.sh
File metadata and controls
67 lines (48 loc) · 1.64 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
/*Basic Queries*/
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 as 'points of Alex' from students WHERE name='Alex';
5- INSERT INTO students VALUES(7,'Rima','23','F',300);
6- UPDATE students
set points = 400
WHERE name='Basma';
7- UPDATE students
set points = 150
WHERE name='Alex';
/*creating table
8 - CREATE TABLE graduates(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Name varchar(255) NOT NULL UNIQUE,
Age INTEGER,
Gender varchar(10),
Points INTEGER,
Graduation date
);
9 - INSERT INTO graduates (Name,Age,Gender,Points)
SELECT name,Age,Gender,Points
FROM students
WHERE name = 'Layal';
10- UPDATE graduates
SET Graduation = DATE('2018-09-08')
WHERE Name = 'Layal';
11- DELETE FROM students WHERE name='layal';
/*joins
12- SELECT employees.Name as employe_name,companies.Name as company,companies.Date
FROM employees
INNER JOIN companies ON
employees.Company = companies.Name;
13- SELECT employees.Name as employees_name FROM employees
INNER JOIN companies
ON companies.Name = employees.Company
WHERE companies.Date<2000
14- SELECT companies.Name as Company_name FROM companies
INNER JOIN employees
ON companies.Name = employees.Company
WHERE employees.Role='Graphic Designer';
/*"Count & Filter"*/
15- SELECT name, max(points) FROM students;
16- select AVG(points) as average FROM students;
17- SELECT count(name) as nb_student_200 from students WHERE Points=500;
18- SELECT name from students where name like '%s%';
19- SELECT * FROM students ORDER by points;