-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinal Project Code
More file actions
76 lines (55 loc) · 2.26 KB
/
Final Project Code
File metadata and controls
76 lines (55 loc) · 2.26 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
create database employee;
use employee;
select emp_id, first_name, last_name, gender, dept
from emp_record order by emp_id asc;
select emp_id, first_name, last_name, gender, dept, emp_rating
from emp_record where emp_rating < 2;
select emp_id, first_name, last_name, gender, dept, emp_rating
from emp_record where emp_rating > 4;
select emp_id, first_name, last_name, gender, dept, emp_rating
from emp_record where emp_rating > 2 and emp_rating < 4;
select concat(first_name, ' ', last_name) as NAME
from emp_record where dept = 'Finance';
select manager_id, count(emp_id)
from emp_record
where manager_id is not null group by manager_id order by manager_id asc;
select * from emp_record where dept = 'healthcare'
union
select * from emp_record where dept = 'finance';
select emp_id, first_name, last_name, role, dept, emp_rating, avg(emp_rating)
from emp_record group by dept;
select role, min(emp_rating), max(emp_rating) from emp_record group by role;
select emp_id, first_name, last_name, exp, rank() over (order by exp desc) as 'Rank'
from emp_record;
create view Test as select emp_id, first_name, last_name, country, salary
from emp_record where salary > 6000;
select * from Test;
select * from (select * from emp_record where exp>10) as tab;
DELIMITER //
CREATE PROCEDURE 3PlusExp()
BEGIN
SELECT * FROM emp_record where exp>3;
END //
delimiter ;
Call 3PlusExp();
delimiter $$
create function check_role(exp integer)
returns VARCHAR(40)
deterministic
begin
declare chck VARCHAR(40);
If exp < 2 then set chck = "JUNIOR DATA SCIENTIST";
elseif exp >=2 and exp < 5 then set chck = "ASSOCIATE DATA SCIENTIST";
elseif exp >=5 and exp < 10 then set chck = "SENIOR DATA SCIENTIST";
elseif exp >= 10 and exp < 12 then set chck = "LEAD DATA SCIENTIST";
elseif exp >= 12 then set chck = "MANAGER";
end if; return (chck);
end $$
delimiter ;
select emp_id, first_name, last_name, role, check_role(exp)
from data_science_team where role != check_role(exp);
CREATE INDEX FirstName ON emp_record (FIRST_NAME(10));
Select EMP_ID, FIRST_NAME, LAST_NAME, SALARY, EMP_RATING, sum((0.05*salary)*emp_rating)
as comm from emp_record group by emp_id order by emp_id asc;
Select country, avg(salary) from emp_record group by country;
select continent, avg(salary) from emp_record group by continent;