Question: I need help with a few SQL database codes to return some resutls! The queries that I need to write are described below this and

I need help with a few SQL database codes to return some resutls! The queries that I need to write are described below this and the tables I have are described below the questions.

--------------------

Now this is the difficult part for me, what would I need to input as the queries to get the results below?

*Find the ssn and last name of every employee whose ssn contains two consecutive 8's, and has a supervisor. Sort the results by ssn.

*For every employee who works for more than 20 hours on any project that is controlled by the research department: Find the ssn, project number, and number of hours. Sort the results by ssn.

*Write a query that consists of one block only. For every employee who works less than 10 hours on any project that is controlled by the department he works for: Find the employee's lname, his department number, project number, the number of the department controlling it, and the number of hours he works on that project. Sort the results by lname.

*For every employee who works on any project that is located in Houston: Find the employees ssn and lname, and the names of his/her dependent(s) and their relationship(s) to the employee. Notice that there will be one row per qualyfing dependent. Sort the results by employee lname.

*Write a query that consists of one block only. For every employee who works for a department that is different from his supervisor's department: Find his ssn, lname, department number; and his supervisor's ssn, lname, and department number. Sort the results by ssn.

*Find pairs of employee lname's such that the two employees in the pair work on the same project for the same number of hours. List every pair once only. Sort the result by the lname in the left column in the result.

*For every employee who has more than one dependent: Find the ssn, lname, and number of dependents. Sort the result by lname

*For every project that has more than 2 employees working on and the total hours worked on it is less than 40: Find the project number, project name, number of employees working on it, and the total number of hours worked by all employees on that project. Sort the results by project number.

*For every employee whose salary is above the average salary in his department: Find the dno, ssn, lname, and salary. Sort the results by department number.

*For every employee who works for the research department but does not work on any one project for more than 20 hours: Find the ssn and lname. Sort the results by lname

*For every employee who works on every project that is controlled by department 4: Find the ssn and lname. Sort the results by lname

-----------------

Tables

-

employee, department, dept_locations, project, works_on, dependent

-

Keys in order of tables

-

fname, lname, ssn, bdate, address, sex, super_ssn, dno

dnumber, dname, mgrssn, mgrstartdate

dnumber, dlocation

pname, pnumber, plocation, dnum

essn, pno, hours

essn, dependent_name, sex, bdate, relationship

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!