Sie sind auf Seite 1von 3

Technological Institute of the Philippines

938 Aurora Blvd. Cubao, Quezon City

College of Information Technology Education

ITE 014 – Information Management

Midterm Period
Displaying Data from Multiple Tables; and Group Functions
Name: Surname, Firstname Mi. Date:
Program / Section: Instructor: Ms. Roxanne A. Pagaduan
Assessment Task: Assignment No.2
The following questions support the attainment of CILOs:
1. Write SQL statements based on given problems and retrieve data in the database.
5. Create query using functions and Joins.
Instructions:
 Read and Answer the following questions.
 Total Points: 25 points
Questions:

1. Which of the following statements is/are TRUE about the following query?
SELECT DISTINCT colors, sizes
FROM items;
_____ a. Each color will appear only once in the results set.
_____ b. Each size will appear only once in the results set.
_____ c. Each color and size combination will appear more than once in the results set.
_____ d. Unique combinations of color and size will appear only once in the results set.

Answer:________

2. Which of the following statements is/are TRUE about the following query? (2 points)
SELECT AVG(NVL(selling_bonus, 0.10))
FROM bonuses;
_____ a. If the selling_bonus column has a null value, 0.10 will be substituted.
_____ b. The datatypes of the values in the NVL clause can be any datatype except date data.
_____ c. This statement will cause an error. There cannot be two functions in the SELECT statement.
_____ d. There will be no null values in the selling_bonus column when the average is calculated.

Answer:________

3. What values will be returned when the statement below is issued? Write your answer in table format. (2 points)

SELECT COUNT(DISTINCT shoe_color) count1,


COUNT(shoe_color) count2
FROM shoes;
Answer:

4. Employees of RAA Fast Foods have birth dates of July 1, 1980, March 19, 1979, and March 30, 1979. If you select
MIN(birthdate), which date will be returned?

Answer:________

5. In the SQL query shown below, which of the following are true about this query? (2 points)
_______ a. Kimberly Grant would not appear in the results set.
_______ b. The GROUP BY clause has an error because the manager_id is not listed in the SELECT clause.
_______ c. Names beginning with Ki will appear after names beginning with Ko.
_______ d. Only salaries greater than 16001 will be in the result set.
_______ e. Last names such as King and Kochhar will be returned even if they don’t have salaries > 16000.

SELECT last_name, MAX(salary)


FROM employees
WHERE last_name LIKE 'K%'
GROUP BY manager_id, last_name
HAVING MAX(salary) >16000
ORDER BY last_name DESC;

Answer:________

6. Write a query that will return both the maximum and minimum average salary grouped by department from the
employees table. (2 points)
Answer:

7. Rewrite the following syntax/query using Oracle Proprietary Join, JOIN ON clause and JOIN USING clause of
ANSI/SQL 99 standard equijoin syntax. (3 points)
SELECT department_id, department_name, location_id, city
FROM departments
NATURAL JOIN locations;
Answer:
8. Using the employees and departments structures of your oracle pdborcl database, create a query using outer join that
shows employee last names, department IDs, and department names. Include all employees even if they are not
assigned to a department. Use Oracle Proprietary Join and equivalent statement using ANSI/SQL 99 standard joins. (2
points)
Answer:

9. Modify the query in problem 8 to return the entire department IDs even if no employees are assigned to them. Provide
two possible queries. (2 points)
Answer:

10. There are one or more errors in each of the following statements. Describe the errors and correct them. (1 point each
error defined and 1 point for each correct the defined error). Total Points: 8 points

a. WHERE e.department_id(+) = d.department_id (+);

How can you return data from two tables that is not in either one?
Possible corrected solutions are:
Answer:

b. SELECT e.employee id, e. last name, d. location id


FROM employees, departments
WHERE e.department_id = d.department_id(+);

Answer: