Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
List the total take-home pay during 2011-2012 for all employees getting a total
take-home-pay < rs.40000
•select empcode,sum(basic+allow-deduct)as pay from salary where salmonth between '2011-01-12' and '2012-01-12' group by empcode having sum(basic+allow-deduct)<40000 order by empcode; List the maximum and minimum basic salary in each grade for grades for grades with start<rs.4000: •select gradecode,max(basic),min(basic) from grade group by gradecode having min(basic)<4000 order by gradecode; List employees along with the names of their supervisors •select e.empcode,e.empname,s.empcode,s.empname from emp e inner join emp s on e.supcode=s.empcode; List employees along with their basic salary: •select empcode,empname,salary.basic from emp inner join salary using (empcode); List employees along with their basic salary: •select empcode,empname,basic from emp natural join salary; List employees along with the names of their supervisors •select e.empcode,e.empname,s.empcode,s.empname from emp e inner join emp s on e.supcode=s.empcode; LIst employees along with the names of their department for which they are working • List employees along with the names of their department for which they are working. The list should have all the departments listed. •select e.empname,d.deptcode from emp e right outer join dept d on e.deptcode = d.deptcode; List employees along with the names of their department for which they are working. The list should have all the departments listed. •select e.empname,d.deptcode from emp e right outer join dept d using (deptcode); full outer join: •select e.empname,e.deptcode,d.deptcode from emp e left join dept d on e.deptcode=d.deptcode union all select e.empcode,e.deptcode,d.deptcode from emp e right join dept d on e.deptcode=d.deptcode where e.deptcode is not null; List the number of officers reporting to each supervisor having more than 3 people working under them. •select supcode,count(*) from emp where gradecode < 10 and supcode in (select supcode from emp group by supcode having count(*)>3) group by supcode; List employees who did not get any promotion since 1990. •select empcode,empname,deptcode from emp e where not exists (select * from history h where h.empcode=e.empcode and changedate>= '1990-01-01'); List employees who get any promotion since 1990. •select empcode,empname,deptcode from emp e where exists (select * from history h where h.empcode=e.empcode and changedate>= '1990-01-01'); list employees who were promoted to officer grade in 1995 correct this •select empcode,empname,deptcode,gradecode,gradelevel from emp where empcode in (select empcode from history where gradecode >= 10 and changedate between '1995-01- 01' and '1995-12-31'); List employees who did not get any promotion since 1990 •select empcode,empname,deptcode from emp where not exists(select * from history where emp.empcode = empcode and changedate > '1990-01-01'); List the second highest salary •select max(basic+allow-deduct)as takehome from salary where (basic+allow-deduct) not in (select max(basic+allow-deduct) from salary); select third highest salary select max(basic+allow-deduct)as takehome from salary where (basic+allow-deduct) in (select max(basic+allow-deduct)as takehome from salary where (basic+allow-deduct) not in (select max(basic+allow-deduct) from salary)); promote shah as salesman •insert into grade values ('GC92','GL2','GC-12-GL-2',5000); •insert into history values('7369','1996-07-01','SLMN','GC92','GL2',5000); (before this command do previous command to avoid error). employ hussein as a temporary employee.(slide 103 changed): •insert into emp (empcode,empname,birthdate,joindate,basicpay) values ('9123','Hussein','2000-01-02','2020-01-02',250); update the salary table for the month(slide 104 changed) •insert into salary select empcode,current_date,basicpay,basicpay*1.5,basicpay*0.3 from emp; delete employee record of kaul: •set foreign_key_checks=0; •delete from emp where empcode='7934'; delete all employee records of filling department: •delete from emp where deptcode='FLNG'; delete the entire contents of salary table •delete from salary; promote gupta as manager(exports): •insert into grade values ('4','GL2','GC-12-GL-2',15000); •update emp set gradecode='4',desigcode='MNGR',basicpay=15000 where empcode='7654'; raise the budget by 25% for all the departments except facilities department.: •update dept set budget=budget*1.25 where deptcode !='FACL';