Final Exam
Final Exam
Final Exam
LPAD
CUT
NVL2
TRIM (*)
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8.
Which comparison operator retrieves a list of values?
IN (*)
LIKE
BETWEENIN
IS NULL
Correct
9.
You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
700
750 (*)
751
751.3
Correct
10.
You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
1200
1282
1282.25
1300 (*)
Correct
Section 1 Lesson 3
(Answer all questions in this section)
11.
Which of the following Date Functions will add calendar months to a date?
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
12.
You need to display the number of months between todays date and each employees hiredate. Which function
should you use?
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Correct
13.
Which of the following SQL statements will correctly display the last name and the number of weeks employed for
all employees in department 90?
SELECT last_name, (SYSDATE-hire_date)/7 AS WEEKS
FROM employees
WHERE department_id = 90; (*)
SELECT last name, (SYSDATE-hire_date)/7 DISPLAY WEEKS
FROM employees
WHERE department id = 90;
SELECT last_name, # of WEEKS
FROM employees
WHERE department_id = 90;
SELECT last_name, (SYSDATE-hire_date)AS WEEK
FROM employees
WHERE department_id = 90;
Correct
14.
Which SELECT statement will NOT return a date value?
SELECT (30 + hire_date) + 1440/24
FROM employees;
SELECT (SYSDATE hire_date) + 10*8
FROM employees; (*)
SELECT SYSDATE TO_DATE(25-JUN-02) + hire_date
FROM employees;
SELECT (hire_date SYSDATE) + TO_DATE(25-JUN-02)
FROM employees;
Correct
15.
The EMPLOYEE table contains these columns:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
HIRE_DATE DATE
EVAL_MONTHS NUMBER(3)
Evaluate this SELECT statement:
SELECT hire_date + eval_months
FROM employee;
The values returned by this SELECT statement will be of which data type?
DATE (*)
NUMBER
DATETIME
INTEGER
Incorrect. Refer to Section 1
Section 2 Lesson 1
(Answer all questions in this section)
16.
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
HIRE_DATE DATE
You need to display HIRE_DATE values in this format:
January 28, 2000
Which SELECT statement could you use? Mark for Review
(1) Points
SELECT TO_CHAR(hire_date, Month DD, YYYY)
FROM employees;
Correct
30.
When joining 3 tables in a SELECT statement, how many join conditions are needed in the WHERE clause? Mark
for Review
(1) Points
0
1
2 (*)
3
Correct
Section 3 Lesson 4
(Answer all questions in this section)
31.
Which statement about outer joins is true? Mark for Review
(1) Points
The tables must be aliased.
The FULL, RIGHT, or LEFT keyword must be included.
The OR operator cannot be used to link outer join conditions. (*)
Outer joins are always evaluated before other types of joins in the query.
Correct
32.
Which two operators can be used in an outer join condition using the outer join operator (+)? Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEENAND and IN
IN and =
Incorrect. Refer to Section 3
33.
Which operator would you use after one of the column names in the WHERE clause when creating an outer join?
Mark for Review
(1) Points
(+) (*)
*
+
=
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34.
Which of the following best describes a natural join? Mark for Review
(1) Points
A join between two tables that includes columns that share the same name, datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
35.
You need to join two tables that have two columns with the same name and compatible data types. Which type of
join would you create to join the tables on both of the columns? Mark for Review
(1) Points
Natural join (*)
Cross join
Outer join
Self-join
Correct
36.
Which of the following conditions will cause an error on a NATURAL JOIN? Mark for Review
(1) Points
When you attempt to write it as an equijoin.
When the NATURAL JOIN clause is based on all columns in the two tables that have the same name.
If it selects rows from the two tables that have equal values in all matched columns.
If the columns having the same names have different data types, then an error is returned. (*)
Correct
Section 4 Lesson 3
(Answer all questions in this section)
37.
Which SELECT clause creates an equijoin by specifying a column name common to both tables? Mark for Review
(1) Points
A HAVING clause
The FROM clause
The SELECT clause
A USING clause (*)
Incorrect. Refer to Section 4
38.
The primary advantage of using JOIN ON is: Mark for Review
(1) Points
The join happens automatically based on matching column names and data types
It will display rows that do not meet the join condition
It permits columns with different names to be joined (*)
It permits columns that dont have matching data types to be joined
Correct
39.
Evaluate this SELECT statement:
SELECT a.lname || , || a.fname as Patient, b.lname || , || b.fname as Physician, c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id);
JOIN admission c
ON (a.patient_id = c.patient_id);
Which clause generates an error? Mark for Review
(1) Points
JOIN physician b
ON (b.physician_id = c.physician_id); (*)
JOIN admission c
ON (a.patient_id = c.patient_id)
Incorrect. Refer to Section 4
40.
Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
having clause
join clause
order by clause
group by clause (*)
Correct
46.
Which statement about group functions is true? Mark for Review
(1) Points
Group functions ignore null values. (*)
Group functions can only be used in a SELECT list.
Group functions can be used in a WHERE clause.
A query that includes a group function in the SELECT list must include a GROUP BY clause.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48.
The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the following? Mark for Review
(1) Points
Only numeric data types (*)
Integers only
Any data type
All except numeric
Correct
47.
What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id; Mark for Review
(1) Points
Displays all the employees and groups them by job.
Displays each job id and the number of people assigned to that job id. (*)
Displays only the number of job_ids.
Displays all the jobs with as many people as there are jobs.
Correct
49.
You need to compute the total salary for all employees in department 10. Which group function will you use? Mark
for Review
(1) Points
MAX
SUM (*)
VARIANCE
COUNT
Correct
50.
Which group functions below act on character, number and date data types?
(Choose more than one answer) Mark for Review
(1) Points
(Choose all correct answers)
SUM
MAX (*)
MIN (*)
AVG
COUNT (*)
Correct
Section 5 Lesson 2
(Answer all questions in this section)
51.
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(9,2)
HIRE_DATE DATE
BONUS NUMBER(7,2)
COMM_PCT NUMBER(4,2)
Which three functions could be used with the HIRE_DATE, LAST_NAME, or SALARY columns? (Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
Correct
52.
Which group function would you use to display the total of all salary values in the EMPLOYEE table? Mark for
Review
(1) Points
SUM (*)
AVG
COUNT
MAX
Correct
53.
The CUSTOMER table contains these columns:
CUSTOMER_ID NUMBER(9)
FNAME VARCHAR2(25)
LNAME VARCHAR2(30)
CREDIT_LIMIT NUMBER (7,2)
CATEGORY VARCHAR2(20)
You need to calculate the average credit limit for all the customers in each category. The average should be
calculated based on all the rows in the table excluding any customers who have not yet been assigned a credit limit
value. Which group function should you use to calculate this value? Mark for Review
(1) Points
AVG (*)
SUM
COUNT
STDDEV
Correct
54.
Which group function would you use to display the highest salary value in the EMPLOYEE table? Mark for Review
(1) Points
AVG
COUNT
MAX (*)
MIN
Correct
55.
Which group function would you use to display the average price of all products in the PRODUCTS table? Mark for
Review
(1) Points
SUM
AVG (*)
COUNT
MAX
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56.
Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employee
WHERE salary > 30000;
Which results will the query display? Mark for Review
(1) Points
The number of employees that have a salary less than 30000.
The total of the SALARY column for all employees that have a salary greater than 30000.
The number of rows in the EMPLOYEE table that have a salary greater than 30000. (*)
The query generates an error and returns no results.
Correct
57.
Evaluate this SELECT statement:
SELECT COUNT(*)
FROM products;
Which statement is true? Mark for Review
(1) Points
The number of rows in the table is displayed. (*)
The number of unique PRODUCT_IDs in the table is displayed.
An error occurs due to an error in the SELECT clause.
Section 6 Lesson 1
(Answer all questions in this section)
61.
The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employees last name, employee identification number, date of hire
and salary. The report should include only those employees who have been with the company for more than one year
and whose salary exceeds $40,000.
Which of the following SELECT statements will accomplish this task? Mark for Review
(1) Points
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Incorrect. Refer to Section 6
62.
Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two. Mark for Review
(1) Points
(Choose all correct answers)
Which clause of the SELECT statement contains a syntax error? Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Correct
66.
The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)
Which two clauses represent valid uses of aggregate functions? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
ORDER BY AVG(salary)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Correct
67.
The PLAYERS and TEAMS tables contain these columns:
PLAYERS
PLAYER_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
TEAM_ID NUMBER
POSITION VARCHAR2 (25)
TEAMS
TEAM_ID NUMBER NOT NULL, Primary Key
TEAM_NAME VARCHAR2 (25)
You need to create a report that lists the names of each team with more than five pitchers.
Which SELECT statement will produce the desired result? Mark for Review
(1) Points
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = PITCHER
GROUP BY t.team_name;
73.
Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS tables.
EMPLOYEE
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
DEPARTMENT
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales department was established. Which of the
following constructs would you use? Mark for Review
(1) Points
a group function
a single-row subquery (*)
the HAVING clause
a MERGE statement
Incorrect. Refer to Section 6
74.
Which best describes a single-row subquery? Mark for Review
(1) Points
a query that returns only one row from the inner SELECT statement (*)
a query that returns one or more rows from the inner SELECT statement
a query that returns only one column value from the inner SELECT statement
a query that returns one or more column values from the inner SELECT statement
Correct
75.
You need to produce a report that contains all employee-related information for those employees who have Brad
Carter as a supervisor. However, you are not sure which supervisor ID belongs to Brad Carter. Which query should
you issue to accomplish this task? Mark for Review
(1) Points
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = Carter);
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = Carter);
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT employee_id
FROM supervisors
WHERE last_name = Carter);
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT employee_id
FROM employees
WHERE last_name = Carter);
(*)
Incorrect. Refer to Section 6
Section 6 Lesson 4
(Answer all questions in this section)
76.
Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
WHERE area_code IN
(SELECT area_code FROM sales WHERE salesperson_id = 20);
Which statement is true about the given subquery? Mark for Review
(1) Points
The outer query executes before the nested subquery.
The results of the inner query are returned to the outer query. (*)
An error occurs if the either the inner or outer queries do not return a value.
Both the inner and outer queries must return a value, or an error occurs.
Correct
77.
Which statement about single-row and multiple-row subqueries is true? Mark for Review
(1) Points
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row subqueries.
Multiple-row subqueries can be used with both single-row and multiple-row operators.
Multiple-row subqueries can only be used in SELECT statements.
Incorrect. Refer to Section 6
78.
Evaluate this SELECT statement:
SELECT customer_id, name
FROM customer
WHERE customer_id IN
(SELECT customer_id
FROM customer
WHERE state_id = GA AND credit_limit > 500.00);
What would happen if the inner query returned null? Mark for Review
(1) Points
An error would be returned.
No rows would be returned by the outer query. (*)
All the rows in the table would be selected.
Only the rows with CUSTOMER_ID values equal to null would be selected.
Incorrect. Refer to Section 6
79.
Which of the following statements contains a comparison operator that is used to restrict rows based on a list of
values returned from an inner query? Mark for Review
(1) Points
SELECT description
FROM d_types
WHERE code IN (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code = ANY (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code <> ALL (SELECT type_code FROM d_songs);
All of the above. (*)
Incorrect. Refer to Section 6
80.
Which of the following is a valid reason why the query below will not execute successfully?
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id =
(SELECT department_id FROM employees WHERE last_name like %u%) Mark for Review
(1) Points
LIKE
BETWEENAND
=, <, and >
Correct
84.
Which best describes a multiple-row subquery? Mark for Review
(1) Points
A query that returns only one row from the inner SELECT statement
A query that returns one or more rows from the inner SELECT statement (*)
A query that returns only one column value from the inner SELECT statement
A query that returns one or more column values from the inner SELECT statement
Correct
85.
A multiple-row operator expects how many values? Mark for Review
(1) Points
One or more (*)
Only one
Two or more
None
Correct
86.
You need to display all the products that cost more than the maximum cost of every product produced in Japan.
Which multiple-row comparison operator could you use? Mark for Review
(1) Points
>ANY (*)
NOT=ALL
IN
>IN
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87.
Assume all the column names are correct. The following SQL statement will execute which of the following?
INSERT INTO departments (department_id, department_name, manager_id, location_id)
VALUES (70, Public Relations, 100, 1700); Mark for Review
(1) Points
100 will be inserted into the department_id column
1700 will be inserted into the manager_id column
70 will be inserted into the department_id column (*)
Public Relations will be inserted into the manager_name column
Correct
88.
You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. What could you use in the
INSERT statement to accomplish this task? Mark for Review
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Incorrect. Refer to Section 7
89.
The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE
You create another table, named FT_STUDENTS, with an identical structure.You want to insert all full-time
students, who have a STU_TYPE_ID value of F, into the new table. You execute this INSERT statement:
INSERT INTO ft_students
(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = F);
What is the result of executing this INSERT statement? Mark for Review
(1) Points
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the FT_STUDENTS table already exists.
An error occurs because you CANNOT use a subquery in an INSERT statement.
An error occurs because the INSERT statement does NOT contain a VALUES clause.
Correct
90.
You need to add a row to an existing table. Which DML statement should you use? Mark for Review
(1) Points
UPDATE
INSERT (*)
DELETE
CREATE
Correct
Section 7 Lesson 2
(Answer all questions in this section)
91.
You need to remove a row from the EMPLOYEE table. Which statement would you use? Mark for Review
(1) Points
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Incorrect. Refer to Section 7
92.
You want to enter a new record into the CUSTOMERS table. Which two commands can be used to create new
rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
INSERT, UPDATE
Correct
93.
The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5)
NAME VARCHAR2(25)
SUBJECT_ID NUMBER(5)
HIRE_DATE DATE
SALARY NUMBER(9,2)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER(5)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)
Which scenario would require a subquery to return the desired results?
You need to display the start date for each class taught by a given teacher.
You need to create a report to display the teachers who were hired more than five years ago.
You need to display the names of the teachers who teach classes that start within the next week.
You need to create a report to display the teachers who teach more classes than the average number of classes taught
by each teacher. (*)
Correct
94.
When the WHERE clause is missing in a DELETE statement, what is the result?
All rows are deleted from the table. (*)
95.
The PLAYERS table contains these columns:
PLAYER_ID NUMBER NOT NULL
PLAYER_LNAME VARCHAR2(20) NOT NULL
PLAYER_FNAME VARCHAR2(10) NOT NULL
TEAM_ID NUMBER
SALARY NUMBER(9,2)
You need to increase the salary of each player for all players on the Tiger team by 12.5 percent. The TEAM_ID
value for the Tiger team is 5960. Which statement should you use?
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
96.
What keyword in an UPDATE statement speficies the columns you want to change? SET (*)
97.
One of your employees was recently married. Her employee ID is still 189, however, her last name is now
Rockefeller. Which SQL statement will allow you to reflect this change?
UPDATE my_employees SET last_name = Rockefeller WHERE employee_ID = 189; (*)
98.
You need to delete a record in the EMPLOYEES table for Tim Jones, whose unique employee identification number
is 348. The EMPLOYEES table contains these columns:
ID_NUM NUMBER(5) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
DELETE FROM employees WHERE id_num = 348; (*)
99.
Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS