DOC PREVIEW
UT Dallas CS 6360 - assignment2

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

For each department whose average employee salary is more than $30,000, retrieve the department name and the number of employees working for that department. select department.dname, count(*) as number_of_emp from department join employee on employee.DNO = department.DNO where (select avg(salary) from employee where employee.dno=department.dno group by employee.dno)>30000 group by department.dname; Same as a, except output the number of male employees instead of the number of employees. select department.dname, count(*) from department join employee on employee.DNO = department.DNO where (select avg(salary) from employee)>30000 and employee.sex = 'M' group by department.dname; Retrieve the names of all employees who work in the department that has the employee with the highest salary among all employees. select fname||' '||lname as Full_name from employee where dno= (select dno from employee where salary = (select max(salary) from employee)); Retrieve the names of employees who make at least $10,000 more than the employee who is paid the least in the company. select fname||' '||lname as Full_name from employee where salary>= (select min(salary)+10000 from employee); Retrieve the names of employees who is making least in their departments and have more than one dependent. select x.fname||' '||x.lname as Full_name from (select e.ssn, e.fname, e.lname from employee e where salary<= (select min(salary) from employee e) group by e.dno,e.ssn, e.fname,e.lname) x, (select d.essn, count(*) from dependent d, employee e where d.ESSN = e.SSN group by d.essn having count(*)>1) y where x.ssn=y.essn; A view that has the department name, manager name and manager salary for every department. create view view1 as select d.dname as Department_Name, e.fname||' '|| e.lname as Manager_Name, e.salary as Manager_salary from employee e join department d on e.ssn=d.mgrssn;  A view that has the department name, its manager's name, number of employees working in that department, and the number of projects controlled by that department (for each department). create view view2 as select m.dname, m.manager_name, n.number_of_emp, t.number_of_projects from (select d.dno, d.dname as dname, e.fname||' '||e.lname as manager_name from department d, employee e where d.mgrssn=e.ssn) m left outer join (select d.dno, count(*) as number_of_emp from employee e, department d where d.dno=e.DNO group by d.dno) n on m.dno=n.dno left outer join (select p.dno,count(p.pno) as number_of_projects from department d, project p where p.dno=d.dno group by p.dno) t on n.dno=t.dno; A view that has the project name, controlling department name, number of employees working on the project, and the total hours per week they work on the project (for each project). create view view3 as select proj_dept.project_name, proj_dept.controlling_dept_name, num_emp.num_of_emp_working,num_emp.number_of_working_hours from (select p.pno, p.pname as project_name, d.dname as controlling_dept_name from department d, project p where p.DNO = d.DNO) proj_dept natural join (select w.pno, count(*) as num_of_emp_working, sum(w.hours) as number_of_working_hours from WORKS_ON w, PROJECT p where w.PNO = p.PNO group by w.pno) num_emp; A view that has the project name, controlling department name, number of employees, and total hours worked per week on the project for each project with more than one employee working on it. create view view4 as select proj_dept.project_name, proj_dept.controlling_dept_name, num_emp.num_of_emp_working,num_emp.number_of_working_hours from (select p.pno, p.pname as project_name, d.dname as controlling_dept_name from department d, project p where p.DNO = d.DNO) proj_dept natural join (select w.pno, count(*) as num_of_emp_working, sum(w.hours) as number_of_working_hours from WORKS_ON w, PROJECT p where w.PNO = p.PNO group by w.pno having count(*)>1) num_emp; A view that has the employee name, employee salary, department that the employee works in, department manager name, manager salary, and average salary for the department. create view view5 as select x.fname, x.salary, x.dname, y.fname as Manager_name, z.aver as Average_salary from (select e.dno,e.fname, e.salary, d.dname from employee e, department d where e.dno=d.dno) x, (select d.dno, e.fname, e.salary from employee e, department d where e.ssn=d.mgrssn) y, (select e.dno, avg(salary) as aver from employee e group by e.dno) z where x.dno=y.dno and y.dno=z.dno;


View Full Document

UT Dallas CS 6360 - assignment2

Documents in this Course
Ch22(1)

Ch22(1)

44 pages

Ch21

Ch21

38 pages

Ch19

Ch19

46 pages

Ch18

Ch18

25 pages

Ch17

Ch17

21 pages

Ch15

Ch15

42 pages

Ch09

Ch09

42 pages

Ch05

Ch05

34 pages

Ch22

Ch22

45 pages

Ch21

Ch21

38 pages

Ch19

Ch19

48 pages

Ch18

Ch18

24 pages

Ch17

Ch17

22 pages

Ch16

Ch16

17 pages

Ch15

Ch15

42 pages

Ch09

Ch09

42 pages

Ch08

Ch08

39 pages

Ch07

Ch07

34 pages

Ch06

Ch06

43 pages

Ch05

Ch05

34 pages

Ch04

Ch04

39 pages

Ch03(2)

Ch03(2)

36 pages

Ch02

Ch02

33 pages

Ch08

Ch08

28 pages

Ch07

Ch07

31 pages

Ch06

Ch06

43 pages

Ch05

Ch05

39 pages

Ch04(1)

Ch04(1)

39 pages

Ch03(1)

Ch03(1)

38 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch24

Ch24

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

48 pages

Ch18

Ch18

24 pages

Ch17

Ch17

22 pages

Ch03(1)

Ch03(1)

38 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch24

Ch24

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

48 pages

Ch18

Ch18

24 pages

Ch17

Ch17

22 pages

Ch08

Ch08

28 pages

Ch07

Ch07

31 pages

Ch06

Ch06

43 pages

Ch05

Ch05

39 pages

Ch04(1)

Ch04(1)

39 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch17

Ch17

25 pages

lab-manual

lab-manual

215 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch17

Ch17

25 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch17

Ch17

25 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch04(1)

Ch04(1)

43 pages

Ch07

Ch07

40 pages

Ch03

Ch03

42 pages

Ch01

Ch01

36 pages

Ch02

Ch02

38 pages

Ch05

Ch05

41 pages

Ch06

Ch06

47 pages

Ch08

Ch08

39 pages

Ch17

Ch17

25 pages

Ch18

Ch18

24 pages

Ch09

Ch09

42 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch17

Ch17

25 pages

Ch09

Ch09

42 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04(1)

Ch04(1)

43 pages

Ch03

Ch03

42 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Load more
Download assignment2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view assignment2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view assignment2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?