You are on page 1of 2

Answer3-

1.select * from employee;


2.select Ssn,Fname,Lname,Address from employee where Dno=7;
3.select Bdate,Address from employee where Fname='Franklin' and Minit='T' and
Lname='wong';
4.select Fname,Minit,Lname,Salary from employee;
5.select distinct Salary from employee;
6.select * from employee where Address like '%Bellaire%';
7.select * from employee where Bdate like '195_%';
8.select * from employee where Dno=5 and Salary between 50000 and 60000;

9.select Fname, Minit, Lname from EMPLOYEE where Superssn is Null;

10.select e.ssn, d.dname from EMPLOYEE e, DEPARTMENT d where e.Dno=d.Dnumber;


or
10.select e.Ssn , d.Dname
from EMPLOYEE as e
left join DEPARTMENT as d
on e.Dno= d.Dnumber;

11.select CONCAT_ws(' ', e.Fname, e.Minit, e.Lname) as 'Employee name', e.Ssn,


d.Dname from EMPLOYEE as e inner join DEPARTMENT as d on e.Dno = d.Dnumber and
d.Dname = 'Research';

12.select p.Pnumber, p.Dnum, e.Lname, e.Bdate, e.Address


from PROJECT as p
inner join DEPARTMENT as d
on p.Dnum = d.Dnumber
inner join EMPLOYEE as e
on d.Mgrssn = e.Ssn and Plocation ='Stafford';

13.select CONCAT_ws(' ', e.Fname, e.Minit ,e.Lname) as 'Employee name',CONCAT_ws('


', s.Fname, s.Minit ,s.Lname) as 'Supervisor'
from EMPLOYEE as e, EMPLOYEE as s
where s.Superssn=e.Ssn;

14.select e.Fname,e.Lname,e.Ssn,d.Dname,d.Mgrssn
from EMPLOYEE as e
cross join DEPARTMENT as d
on e.Ssn= d.Mgrssn ;
or
14.select d.Dname , CONCAT_Ws(' ', e.Fname, e.Minit ,e.Lname) as 'Employee name'
from EMPLOYEE e, DEPARTMENT d;

15.(select distinct Pnumber


from PROJECT,DEPARTMENT,EMPLOYEE
where Dnum=Dnumber and Mgrssn=Ssn and Lname="Narayan")
union
(select distinct Pnumber
from PROJECT,WORKSON,EMPLOYEE
where Pnumber=Pno and Essn=ssn and Lname="Narayan");

16.select Fname,Lname, 1.5*Salary as increased_Sal


from EMPLOYEE,WORKSON,PROJECT
where Ssn=Essn and Pno=Pnumber and Pname="productX";

or
16.select CONCAT_ws(' ', e.Fname,e.Minit,e.Lname) as 'Name', e.Salary as 'Actual
salary' , (e.Salary*1.15) as 'Increased salary'
from EMPLOYEE as e
inner join WORKSON as w
on e.Ssn = w.Essn
inner join PROJECT as p
on w.Pno = p.Pnumber and p.Pname = 'ProductX';

#if we want department name also then:


select e.Dno,(select Dname from DEPARTMENT where Dnumber=e.Dno) as 'Deptname',
CONCAT_ws(' ', e.Fname,e.Minit,e.Lname) as Name, e.Salary as 'Actual salary' ,
(e.Salary*1.15) as 'Increased salary'
from EMPLOYEE as e
inner join WORKSON as w
on e.Ssn = w.Essn
inner join PROJECT as p
on w.Pno = p.Pnumber and p.Pname = 'ProductX';

You might also like