-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComp_Data_1_Part4
More file actions
75 lines (56 loc) · 1.98 KB
/
Comp_Data_1_Part4
File metadata and controls
75 lines (56 loc) · 1.98 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
Hello. We already created all the tables and populated them with information. So that's our schema. Now we are ready to query
our database.
-----Find all employees---
SELECT * FROM employee;
-----Find all client----
SELECT * FROM client;
----Find all employees ordered by salary---
SELECT * FROM employee
ORDER BY salary;
----Find all employees ordered by salary in descending form---
SELECT * FROM employee
ORDER BY salary DESC;
----Find all employees ordered by sex then name----
SELECT * FROM employee
ORDER BY sex,first_name,last_name;
----Find the first 5 employees in the table
SELECT * FROM employee
WHERE emp_id<=104;
----Find the first 5 employees using LIMIT----
SELECT * FROM employee
LIMIT 5;
----Find the first and last names of all employees----
SELECT first_name,last_name
FROM employee;
-----Find the forenames and surnames of all employees----
SELECT first_name AS forename,last_name AS surname
FROM employee;
-----Find out all the different genders----
SELECT DISTINCT sex
FROM employee;
----Find out all the different branch IDs----
SELECT DISTINCT branch_id
FROM employee;
-----Find all male employees---
SELECT first_name,last_name FROM employee
WHERE sex='M';
------Find all employees at branch 2----
SELECT first_name,last_name FROM employee
WHERE branch_id=2;
----Find all employee IDs and names who were born after 1969----
SELECT emp_id,first_name,last_name
FROM employee
WHERE birth_date>'1969-12-31';
-----Find all female employees at branch 2----
SELECT first_name,last_name
FROM employee
WHERE sex='F' AND branch_id=2;
-----Find all female employees who are female and were born after 1969 or who make over 80000----
SELECT * FROM employee
WHERE sex='F' AND (birth_date>'1969-12-31' OR salary>80000);
-----Find all employees born between 1970 and 1975,inclusive----
SELECT * FROM employee
WHERE birth_date BETWEEN '1970-01-01' AND '1975-12-31';
-----Find all employees named Jim,Michael and Johnny----
SELECT * FROM employee
WHERE first_name IN ('Jim','Michael','Johnny');