Queries
Queries
1. Retrieve the birth date and address of the employee(s) whose name is ‘John B. Smith’.
2. Retrieve the name and address of all employees who work for the ‘Research’ department.
3. For every project located in ‘Stafford’, list the project number, the controlling department
number, and the department manager’s last name, address, and birth date.
4. For each employee, retrieve the employee’s first and last name and the first and last name of his
or her immediate supervisor.
5. Retrieve the salary of every employee
6. Display all distinct salary values.
7. Make a list of all project numbers for projects that involve an employee whose last name is
‘Smith’, either as a worker or as a manager of the department that controls the project.
8. Retrieve all employees whose address is in Houston, Texas.
9. Find all employees who were born during the 1950s.
10. Show the resulting salaries if every employee working on the ‘ProductX’ project is given a 10%
raise.
11. Retrieve all employees in department 5 whose salary is between $30,000 and $40,000.
12. Retrieve a list of employees and the projects they are working on, ordered by department and,
within each department, ordered alphabetically by last name, then first name.
13. Retrieve the names of all employees who do not have supervisors.
14. Retrieve the name of each employee who has a dependent with the same first name and is the
same sex as the employee.
15. Retrieve the names of employees who have no dependents.
16. List the names of managers who have at least one dependent.
17. Retrieve the Social Security numbers of all employees who work on project numbers 1, 2, or 3
18. Find the sum of the salaries of all employees, the maximum salary, the minimum salary, and the
average salary.
19. Find the sum of the salaries of all employees of the ‘Research’ department, as well as the
maximum salary, the minimum salary, and the average salary in this department.
20. Retrieve the total number of employees in the company
21. Retrieve the number of employees in the ‘Research’ department
22. Count the number of distinct salary values in the database.
23. For each department, retrieve the department number, the number of employees in the
department, and their average salary.
24. For each project, retrieve the project number, the project name, and the number of employees
who work on that project.
25. For each project on which more than two employees work, retrieve the project number, the
project name, and the number of employees who work on the project.
26. For each project, retrieve the project number, the project name, and the number of employees
from department 5 who work on the project
27. For each department that has more than five employees, retrieve the department number and
the number of its employees who are making more than $40,000.
Home assignment