You are on page 1of 2

use yohana

create table employees


(
empid int primary key,
empname char(20),
sex char(20),
birth_date datetime
)
create table department
(
depid int primary key,
depname varchar(50),
)
create table job_position
(
jobid int primary key,
job_title varchar(50),
salary float,
required_experience int,
depid int foreign key references department(depid),
empid int foreign key references employees (empid)
)
insert into employees
values(101,'wendu','male','10/02/80'),
(102,'gizat','male','10/02/99'),
(103,'almaz','female','10/02/77'),
(104,'tadele','male','10/02/44'),
(105,'marta','female','10/02/54'),
(106,'biru','male','10/02/94'),
(107,'hana','female','10/02/49'),
(108,'tamirat','male','10/02/82'),
(109,'selam','female','10/02/69'),
(110,'asmaret','female','10/02/67')

insert into job_position


values(2001,'HNS',2500,2,301,101),
(2002,'DBA',3700,3,302,102),
(2003,'communication',1900,9,303,103),
(2004,'electrical',1700,5,304,104),
(2005,'biomedical',4800,6,305,105),
(2006,'History',2500,7,301,106),
(2007,'geography',5432,8,303,107)

insert into department


values(301,'computer'),
(302,'hns'),
(303,'dba'),
(304,'sicience'),
(305,'sport')

delete from job_position where salary<3000


update job_position set salary=salary+500
update job_position set salary=salary+500 where salary<3000
select COUNT(*) from job_position

select*from employees
select*from job_position
select*from department

select empname,job_title,salary,depname from employees inner join job_position


on
employees.empid= job_position.empid
inner join department on department.depid =job_position.depid where
sex='female'

select depname,COUNT(*)as member_of_employee from employees inner join


job_position on
employees.empid= job_position.empid
inner join department on department.depid =job_position.depid group by depname

select employees. empid,empname,depname,salary from employees inner join


job_position on
employees.empid= job_position.empid
inner join department on department.depid =job_position.depid order by salary
desc

select count(*) from employees where employees.empid in (select


job_position.empid
from job_position where job_position.depid in (select depid, count(*)from
job_position group by depid ))

(select job_position.jobid from job_position where department.depid in (select


job_position.depid from job_position))
group by depname)

You might also like