Вы находитесь на странице: 1из 2

Homework 6

1. Create a Cartesian product that displays the columns in the d_play_list_items and the d_track_listings in the DJs on Demand database. 2. Correct the Cartesian product produced in question 1 by creating an equijoin using a common column. 3. Write a query to display the title, type description, and artist from the DJs on Demand database. 4. Using the Oracle database, create a query that returns the employee last name, salary, and jobgrade level based on the salary. Select the salary between the lowest and highest salaries. 5. Create a query of the Oracle database that shows employee last names, department IDs, and department names. Include all employees even if they are not assigned to a department. 6. Modify the query in problem 2 to return all the department IDs even if no employees are assigned to them. 7. Display the employees last name and employee number along with the managers last name and manager number. Label the columns: Employee, Emp#, Manager, and Mgr#, respectively.

8. Display the names and hire dates for all employees who were hired before their managers, along with their managers names and hire dates. Label the columns Employee, Emp Hired, Manager, and Mgr Hired, respectively.

9. Write a report that shows the hierarchy for Lex De Haans department. Include last name, salary and department id in the report.

10. Create a cross-join that displays the last name and department name from the employees and departments tables. 11. Create a query that uses a natural join to join the departments table and the locations table by the location_id column. Display the department id and name, location id, and city.

12. Create a query that uses a natural join to join the departments table by the location_id column. Restrict the output to only department IDs of 20 and 50. Display the department id and name, location id, and city.

13. Join the Oracle database locations and departments table using the location_id column. Limit the results to location 1400 only. 14. Display country name, region ID and region name for Americas.

The following questions use the JOINON syntax: 15. Write a statement that displays the employee ID, first name, last name, manager ID, manager first name, and manager last name for every employee in the employees table. Hint: this is a selfjoin. 16. Query and display manager ID, department ID, department name, first name, and last name for all employees in departments 80, 90, 110, and 190. 17. Display the employees last name and employee number along with the managers last name and manager number. Label the columns Employee, Emp#, Manager, and Mgr#, respectively. 18. Modify problem 4 to display all employees, including those who have no manager. Order the results by the employee number.

Вам также может понравиться