Using the Company database in Oracle, construct SQL queries for the following (note: I will make the files to create and populate the Company database available on Isadore shortly):
1.For an employee database that looks as follows, P,ease find all the queries mentioned below.
Select lname, address
from Employee as e
Inner join dependent as d
Using (emp_id)
where e.last_name=d.dependent_name and e.designation like 'Manager'
2.
Select fname, lname
from employee as e
where e.superssn =(Select ssn from employee where fname like 'Franklin' and lname like 'Wong');
3.
select fname,lname from employee as e
inner join department as d
on
e.dno=d.number
inner join works_on as w
on
e.ssn=w.essn
inner join project as p
w.pno=p.pnumber
where d.dname like 'Research' and w.hours>20 and p.pname="Computerization";
4.
Select fname,lname
from employee as e
where e.superssn is not null and e.ssn not in (select essn from dependent);
5.
select dname, min(salary) as Min_Salary
from department as d
inner join employee as e
on e.dno=d.dnumber
group by dname;
6.
select dname, count(ssn) as Count_Emp
from department as d
inner join employee as e
on e.dno=d.dnumber
where e.salary>30000
group by dname;
7.
select avg(salary) as avg_salary
from employee as e
inner join works_on as w
on e.ssn=w.essn
where e.sex= 'Female' ;
8.
select fname,lname
from employee as e
inner join works_on as w
on e.ssn=w.essn
where w.pno in (select pno from works_on as w
inner join employee as e
on e.ssn=w.essn
where e.fname='John' and lname='Smith');
9.
select fname,lname , adress from employee as e
inner join works_on as w
on e.ssn=w.essn
inner join project as p
on w.pno=p.pnumber
inner join dept_location as dl
on e.dno=dl.dnumber
where
p.plocation like 'Houston' and dl.dlocation not like 'Houston' ;
10.
select fname,lname, sname, salary
from employee as e
inner join department as d
on e.dno=d.dnumber
where d.dname ='Research' ;
11.
Select pname,dnumber,count(ssn) as No_of_emp,hours
from employees as e
inner join department as d
on d.dnumber=e.dno
inner join works_on as w
on w.essn=e.ssn
inner join project as p
on w.pno =p.pnumber
group by pname;
Please mention any doubts in comments.Thanks
Get Answers For Free
Most questions answered within 1 hours.