oracle mid exam totpart1
TRANSCRIPT
![Page 1: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1.jpg)
1. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
2. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
![Page 2: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/2.jpg)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Correct
You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
![Page 3: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/3.jpg)
CONCAT, SUBSTR, LOWER (*)
Correct
4. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 11.00
You query the database and return the value 40. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
![Page 4: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/4.jpg)
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
(*)
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
Correct
You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
![Page 5: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/5.jpg)
Which value is returned by this command?
Mark for Review
(1) Points
1
2
13 (*)
17
Correct
6. You need to display the number of characters in each customer's last name. Which function should
you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
![Page 6: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/6.jpg)
SUBSTR
Correct
7. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
![Page 7: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/7.jpg)
Correct
. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Correct
9. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
![Page 8: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/8.jpg)
(1) Points
1 (*)
2
25
0
Correct
10. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
![Page 9: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/9.jpg)
Incorrect. Refer to Section 1 Lesson 1
11. Which function would you use to return the current database server date and time? Mark for
Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Correct
12. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
![Page 10: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/10.jpg)
MONTHS_BETWEEN (*)
Correct
13. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
14. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
![Page 11: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/11.jpg)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
15. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
![Page 12: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/12.jpg)
No value is returned because the SELECT statement generates an error.
Incorrect. Refer to Section 1
16. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct
17. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
![Page 13: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/13.jpg)
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Incorrect. Refer to Section 2
18. 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?
![Page 14: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/14.jpg)
Mark for Review
(1) Points
SELECT TO_CHAR(hire_date, Month DD, YYYY)
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
FROM employees;
(*)
SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
Incorrect. Refer to Section 2
19. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
![Page 15: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/15.jpg)
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
Incorrect. Refer to Section 2
20. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
![Page 16: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/16.jpg)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Incorrect. Refer to Section 2
![Page 17: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/17.jpg)
21. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
22. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
![Page 18: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/18.jpg)
Correct
23. When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null? Mark for Review
(1) Points
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
FROM student_accounts;
![Page 19: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/19.jpg)
Incorrect. Refer to Section 2
24. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Correct
25. 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
![Page 20: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/20.jpg)
2 (*)
3
Correct
26. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
![Page 21: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/21.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
(*)
Correct
27. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
Mark for Review
(1) Points
![Page 22: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/22.jpg)
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
28. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated at least $100,000 in revenue.
![Page 23: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/23.jpg)
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
![Page 24: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/24.jpg)
Correct
29. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Incorrect. Refer to Section
30. Which statement about the join syntax of a SELECT statement is true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
![Page 25: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/25.jpg)
The WHERE clause represents the join criteria. (*)
Incorrect. Refer to Section 3
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. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
![Page 26: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/26.jpg)
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Correct
33. 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 =
BETWEEN...AND... and IN
IN and =
![Page 27: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/27.jpg)
Incorrect. Refer to Section 3
34. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Incorrect. Refer to Section 4
35. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table.
Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
![Page 28: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/28.jpg)
An inner join
A full outer join
Incorrect. Refer to Section 4
36. 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
37. Which SELECT clause creates an equijoin by specifying a column name common to both tables?
Mark for Review
(1) Points
![Page 29: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/29.jpg)
A HAVING clause
The FROM clause
The SELECT clause
A USING clause (*)
Correct
38. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Incorrect. Refer to Section 4
![Page 30: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/30.jpg)
39. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in
sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about orders placed by
customers who reside in Nashville . Which query should you issue to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
![Page 31: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/31.jpg)
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Correct
40. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
![Page 32: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/32.jpg)
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
![Page 33: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/33.jpg)
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Incorrect. Refer to Section 4
![Page 34: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/34.jpg)
41. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
![Page 35: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/35.jpg)
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Incorrect. Refer to Section 4
43. What should be included in a SELECT statement to return NULL values from all tables? Mark for
Review
(1) Points
natural joins
left outer joins
![Page 36: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/36.jpg)
full outer joins (*)
right outer joins
Incorrect. Refer to Section 4
44. If a select list contains both a column as well as a group function then what clause is required?
Mark for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
Incorrect. Refer to Section 5
45. Evaluate this SELECT statement:
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
![Page 37: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/37.jpg)
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Incorrect. Refer to Section 5
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.
![Page 38: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/38.jpg)
A query that includes a group function in the SELECT list must include a GROUP BY clause.
Incorrect. Refer to Section 5
47. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Incorrect. Refer to Section 5
48. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the following? Mark
for Review
(1) Points
![Page 39: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/39.jpg)
Only numeric data types (*)
Integers only
Any data type
All except numeric
Correct
49. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
![Page 40: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/40.jpg)
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
50. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
![Page 41: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/41.jpg)
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect. Refer to Section 5
51. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
![Page 42: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/42.jpg)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect. Refer to Section 5
52. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
Mark for Review
(1) Points
AVG
COUNT
MAX
MIN (*)
Incorrect. Refer to Section 5
![Page 43: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/43.jpg)
53. You need to calculate the average salary of employees in each department. Which group function
will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
Correct
54. 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 (*)
![Page 44: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/44.jpg)
AVG
COUNT (*)
Correct
55. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
![Page 45: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/45.jpg)
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Incorrect. Refer to Section 5
56. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
![Page 46: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/46.jpg)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
Incorrect. Refer to Section 5
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
![Page 47: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/47.jpg)
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Incorrect. Refer to Section 5
58. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
SELECT
![Page 48: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/48.jpg)
UNLIKE
Incorrect. Refer to Section 5
59. 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.
An error occurs because no WHERE clause is included in the SELECT statement.
Incorrect. Refer to Section 5
![Page 49: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/49.jpg)
60. 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)
Incorrect. Refer to Section 6
![Page 50: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/50.jpg)
61. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
![Page 51: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/51.jpg)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Correct
62. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
![Page 52: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/52.jpg)
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
Correct
63. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
![Page 53: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/53.jpg)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
![Page 54: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/54.jpg)
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
64. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
![Page 55: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/55.jpg)
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Correct
65. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
![Page 56: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/56.jpg)
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section
66. 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
![Page 57: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/57.jpg)
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;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
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 HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
(*)
![Page 58: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/58.jpg)
Incorrect. Refer to Section 6
67. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Incorrect. Refer to Section 6
68. Using a subquery in which clause will return a syntax error? Mark for Review
(1) Points
WHERE
FROM
HAVING
![Page 59: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/59.jpg)
There are no places you cannot place subqueries. (*)
Incorrect. Refer to Section 6
69. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
The result of the main query is used with the subquery
Correct
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
![Page 60: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/60.jpg)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
![Page 61: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/61.jpg)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
Incorrect. Refer to Section 6
71. The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES
EMP_ID NUMBER(10) NOT NULL PRIMARY KEY
FNAME VARCHAR2(30)
LNAME VARCHAR2(30)
![Page 62: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/62.jpg)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMP_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin
during the year 2001?
Mark for Review
(1) Points
SELECT order_id, total
FROM ORDERS (SELECT emp_id FROM employees WHERE lname = 'Franklin')
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT (SELECT emp_id FROM employees WHERE lname = 'Franklin') AND order_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
![Page 63: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/63.jpg)
SELECT order_id, emp_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE emp_id = (SELECT emp_id FROM employees WHERE lname = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
Correct
72. the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
![Page 64: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/64.jpg)
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Incorrect. Refer to Section 6
73. 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 *
![Page 65: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/65.jpg)
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
![Page 66: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/66.jpg)
WHERE supervisor_id =
(SELECT employee_id
FROM employees
WHERE last_name = 'Carter');
(*)
Incorrect. Refer to Section 6
74. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Incorrect. Refer to Section 6
![Page 67: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/67.jpg)
75. 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
Incorrect. Refer to Section 6
76. 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
![Page 68: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/68.jpg)
Incorrect. Refer to Section 6
77. 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
![Page 69: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/69.jpg)
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. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
![Page 70: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/70.jpg)
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Incorrect. Refer to Section 6
80. Which of the following best describes the meaning of the ANY operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
![Page 71: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/71.jpg)
Correct
81. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review
(1) Points
ALL
ANY
= (*)
>
Incorrect. Refer
82. What would happen if you attempted to use a single-row operator with a multiple-row subquery?
Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
![Page 72: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/72.jpg)
The data returned may or may not be correct.
Incorrect. Refer to Section 6
83. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
![Page 73: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/73.jpg)
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
![Page 74: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/74.jpg)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
![Page 75: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/75.jpg)
Nothing, it will run without problems.
Incorrect. Refer to Section 6
86. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
![Page 76: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/76.jpg)
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Incorrect. Refer to Section 6
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 (*)
![Page 77: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/77.jpg)
'Public Relations' will be inserted into the manager_name column
Incorrect. Refer to Section 7
88. 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
Incorrect. Refer
89. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
![Page 78: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/78.jpg)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Incorrect. Refer to Section 7
90. 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
![Page 79: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/79.jpg)
a subquery (*)
a function
Correct
91. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
![Page 80: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/80.jpg)
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Incorrect. Refer to Section 7
92. 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
![Page 81: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/81.jpg)
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct
93. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
![Page 82: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/82.jpg)
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Correct
94. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
![Page 83: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/83.jpg)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee number 89898. Currently, all employees in department 10 have the
same salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employee
SET salary = SELECT salary
FROM employee
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
![Page 84: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/84.jpg)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
Incorrect. Refer to Section 7
95. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Incorrect. Refer to Section 7
96. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
![Page 85: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/85.jpg)
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
97. 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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
![Page 86: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/86.jpg)
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
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?
Mark for Review
(1) Points
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
DELETE * FROM employees WHERE id_num = 348;
![Page 87: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/87.jpg)
DELETE 'jones' FROM employees;
Correct
99. You need to update the expiration date of products manufactured before June 30th . In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
Correct
100. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table
using one UPDATE statement. Which clause should you include in the UPDATE statement to update
multiple columns? Mark for Review
(1) Points
the USING clause
![Page 88: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/88.jpg)
the ON clause
the WHERE clause
the SET clause (*)
Correct
1. You need to display each employee's name in all uppercase letters. Which function should you use?
Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
2. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
TRUNC
![Page 89: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/89.jpg)
SUBSTR (*)
CONCAT
3. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employee;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEE table.
The email address of each employee in the EMPLOYEE table.
The number of characters for each value in the EMAIL column in the employees table. (*)
The maximum number of characters allowed in the EMAIL column.
![Page 90: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/90.jpg)
4. You need to display the number of characters in each customer's last name. Which function
should you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
5. Which functions can be used to manipulate character, number, and date column values?
Mark for Review
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
![Page 91: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/91.jpg)
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTH
6. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
![Page 92: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/92.jpg)
7. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
![Page 93: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/93.jpg)
IS NULL
The SUBSTR character function returns a portion of a string beginning at a defined character
position to a specified length. (*)
10. Which two functions can be used to manipulate number or date column values, but NOT
character column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
![Page 94: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/94.jpg)
CONCAT
11. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
12. You need to display the current year as a character value (for example: Two Thousand and One).
Which element would you use? Mark for Review
(1) Points
![Page 95: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/95.jpg)
RR
YY
YYYY
YEAR (*)
13. You need to display the number of months between today's date and each
employee's hiredate. Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
![Page 96: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/96.jpg)
MONTHS_BETWEEN (*)
14. Which of the following SQL statements will correctly display the last name and the
number of weeks employed for all employees in department 90? Mark for Review
(1) Points
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;
![Page 97: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/97.jpg)
SELECT last_name, (SYSDATE-hire_date)AS WEEK
FROM employees
WHERE department_id = 90;
16. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
17. Which two statements concerning SQL functions are true? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
![Page 98: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/98.jpg)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
18. Which three statements concerning explicit data type conversions are true?
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
![Page 99: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/99.jpg)
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string. (*)
19. 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
![Page 100: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/100.jpg)
SELECT TO_CHAR(hire_date, Month DD, YYYY)
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
FROM employees;
(*)
SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
20. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
![Page 101: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/101.jpg)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
21. If you use the RR format when writing a query using the date 27-OCT-17 and the
year is 2001, what year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
![Page 102: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/102.jpg)
Incorrect Incorrect. Refer to Section 2
Previous Page 21 of 100 Next Summary
22. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
![Page 103: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/103.jpg)
The statement would fail because values cannot be divided by null.
23. Which of the following General Functions will return the first non-null expression in the
expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
24. You need to replace null values in the DEPT_ID column with the text "N/A".
Which functions should you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
![Page 104: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/104.jpg)
TO_CHAR and NULLIF
25. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Incorrect Incorrect. Refer to Section 3
26. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
![Page 105: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/105.jpg)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
![Page 106: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/106.jpg)
A syntax error
27. 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
Incorrect Incorrect. Refer to Section 3
28. You need to provide a list of the first and last names of all employees who work in the Sales
department who earned a bonus and had sales over $50,000. The company president would like the
sales listed starting with the highest amount first. The EMPLOYEES table and the SALES_DEPT table
contain the following columns:
![Page 107: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/107.jpg)
EMPLOYEES
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MGR VARCHAR2(30)
BONUS NUMBER(10)
EMP_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
![Page 108: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/108.jpg)
WHERE e.emp_id = s.emp_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
WHERE e.emp_id = s.emp_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
29. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
![Page 109: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/109.jpg)
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
![Page 110: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/110.jpg)
(*)
30. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
![Page 111: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/111.jpg)
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
31. The EMPLOYEE_ID column in the EMPLOYEE table corresponds to the EMPLOYEE_ID column of
the ORDER table. The EMPLOYEE_ID column in the ORDER table contains null values for rows that you
need to display.
Which type of join should you use to display the data? Mark for Review
(1) Points
natural join
![Page 112: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/112.jpg)
self-join
outer join (*)
equijoin
32. 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.
33. Which of the following best describes the function of an outer join? Mark
for Review
(1) Points
![Page 113: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/113.jpg)
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and the far right column
in the other table.
An outer join will return data only if both tables contain an identical pair of columns.
An outer join will return all rows that meet the join criteria and will return NULL values from one
table if no rows from the other table satisfy the join criteria. (*)
34. 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.
![Page 114: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/114.jpg)
If the columns having the same names have different data types, then an error is returned. (*)
35. A join between tables where the result set includes matching values from both tables
but does NOT return any unmatched rows could be called which of the following? (Choose three)
Mark for Review
(1) Points
(Choose all correct answers)
Equijoin (*)
Self join (*)
Nonequijoin
Simple join (*)
full outer join
36. 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
![Page 115: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/115.jpg)
Natural join (*)
Cross join
Outer join
Self-join
37. Which of the following statements is the simplest description of a nonequijoin? Mark
for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
![Page 116: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/116.jpg)
A join that joins a table to itself
38. 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
![Page 117: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/117.jpg)
ON (a.patient_id = c.patient_id)
39. 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 don't have matching data types to be joined
40. For which condition would you use an equijoin query with the USING keyword?
Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of
columns in the join condition. (*)
![Page 118: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/118.jpg)
The ORDER table contains a column that has a referential constraint to a column in the
PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID column
in the ORDER table contains null values that need to be displayed.
41. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
![Page 119: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/119.jpg)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
42. Which type of join returns rows from one table that have NO direct match in the other table?
Mark for Review
(1) Points
equijoin
self join
outer join (*)
![Page 120: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/120.jpg)
natural join
43. What should be included in a SELECT statement to return NULL values from all tables?
Mark for Review
(1) Points
natural joins
left outer joins
full outer joins (*)
right outer joins
44. If a select list contains both a column as well as a group function then what clause is
required? Mark for Review
(1) Points
having clause
join clause
![Page 121: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/121.jpg)
order by clause
group by clause (*)
45. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEE table.
The latest hire date in the EMPLOYEE table.
![Page 122: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/122.jpg)
The hire dates in the EMPLOYEE table that contain NULL values
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.
47. Group functions can be nested to a depth of? Mark for Review
(1) Points
![Page 123: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/123.jpg)
three
four
two (*)
Group functions cannot be nested.
48. 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
![Page 124: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/124.jpg)
49. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
![Page 125: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/125.jpg)
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect Incorrect. Refer to Section 5
50. You need to calculate the standard deviation for the cost of products produced in the
Birmingham facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
51. Group functions return a value for ________________ and ________________ null values in
their computations. Mark for Review
(1) Points
![Page 126: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/126.jpg)
a row set, ignore (*)
each row, ignore
a row set, include
each row, include
52. You need to calculate the average salary of employees in each department. Which group
function will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
![Page 127: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/127.jpg)
AVERAGE
53. 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
54. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
![Page 128: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/128.jpg)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
55. The EMPLOYEES table contains these columns:
![Page 129: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/129.jpg)
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 (*)
![Page 130: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/130.jpg)
COUNT (*)
56. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark
for Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
![Page 131: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/131.jpg)
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_it
58. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
![Page 132: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/132.jpg)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
![Page 133: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/133.jpg)
(*)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
59. 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.
![Page 134: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/134.jpg)
An error occurs due to an error in the SELECT clause.
An error occurs because no WHERE clause is included in the SELECT statement.
60. 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)
SELECT department_id, AVG(salary)
![Page 135: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/135.jpg)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
61. 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
![Page 136: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/136.jpg)
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;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
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 HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
![Page 137: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/137.jpg)
(*)
62. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
![Page 138: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/138.jpg)
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
3. 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)
![Page 139: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/139.jpg)
ORDER BY AVG(salary)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
65. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
![Page 140: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/140.jpg)
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
66. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id
FROM employee
GROUP BY dept_id;
How are the results of this statement sorted?
Mark for Review
(1) Points
Ascending order by dept_id (*)
Descending order by dept_id
Ascending order by cumulative salary
![Page 141: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/141.jpg)
Descending order by cumulative salary
67. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
![Page 142: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/142.jpg)
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect Incorrect. Refer to Section 6
Previous Page 67 of 100 Next Summary
68. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
![Page 143: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/143.jpg)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Incorrect Incorrect. Refer to Section 6
![Page 144: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/144.jpg)
Previous Page 68 of 100 Next Summary
69. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
=
LIKE
70. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
![Page 145: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/145.jpg)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
71. Using a subquery in which clause will return a syntax error? Mark for Review
(1) Points
WHERE
![Page 146: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/146.jpg)
FROM
HAVING
There are no places you cannot place subqueries. (*)
72. You need to display all the players whose salaries are greater than or equal to John Brown's
salary. Which comparison operator should you use? Mark for Review
(1) Points
=
>
<=
>= (*)
![Page 147: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/147.jpg)
73. 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
74. 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
![Page 148: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/148.jpg)
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
![Page 149: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/149.jpg)
75. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row. (*)
76. Which operator or keyword cannot be used with a multiple-row subquery? Mark for
Review
(1) Points
ALL
ANY
![Page 150: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/150.jpg)
= (*)
>
77. Which comparison operator would you use to compare a value to every value returned
by a subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Correct Correct
![Page 151: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/151.jpg)
78. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
 FROM teams
 WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
![Page 152: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/152.jpg)
79. What would happen if you attempted to use a single-row operator with a multiple-row
subquery? Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Incorrect Incorrect. Refer to Section 6
80. Which best describes a multiple-row subquery? Mark for Review
(1) Points
A query that returns only one row from the inner SELECT statement
![Page 153: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/153.jpg)
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
81. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
![Page 154: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/154.jpg)
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
 FROM manufacturers
 WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
 FROM manufacturers
 WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
 FROM manufacturers m
 JOIN part p ON (m.id = p.manufacturers_id));
![Page 155: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/155.jpg)
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
 FROM manufacturers)
 WHERE cost > AVG(cost);
Correct Correct
Previous Page 81 of 100 Next Summary
82. Which of the following best describes the meaning of the ANY operator? Mark for
Review
(1) Points
Equal to any member in the list
![Page 156: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/156.jpg)
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
83. 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 SEL
![Page 157: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/157.jpg)
84. Which statement about the ANY operator when used with a multiple-row subquery is
true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
85. You need to create a SELECT statement that contains a multiple-row subquery, which
comparison operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
![Page 158: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/158.jpg)
BETWEEN...AND...
=, <, and >
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
87. The STUDENTS table contains these columns:
![Page 159: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/159.jpg)
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.
![Page 160: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/160.jpg)
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.
88. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column
You issue this statement:
INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);
What row data did you add to the table?
Mark for Review
(1) Points
![Page 161: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/161.jpg)
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
89. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
![Page 162: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/162.jpg)
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
90. You need to add a row to an existing table. Which DML statement should you use? Mark
for Review
![Page 163: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/163.jpg)
(1) Points
UPDATE
INSERT (*)
DELETE
CREATE
91. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE
table using one UPDATE statement. Which clause should you include in the UPDATE statement to
update multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
![Page 164: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/164.jpg)
the WHERE clause
the SET clause (*)
92. What keyword in an UPDATE statement speficies the columns you want to change? Mark
for Review
(1) Points
SELECT
WHERE
SET (*)
HAVING
93. One of the sales representatives, Janet Roper, has informed you that she was recently married,
and she has requested that you update her name in the employee database. Her new last name is
Cooper. Janet is the only person with the last name of Roper that is employed by the company. The
EMPLOYEES table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
![Page 165: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/165.jpg)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
![Page 166: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/166.jpg)
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
94. Which two commands can be used to modify existing data in a database row? Mark for
Review
(1) Points
(Choose all correct answers)
DELETE
INSERT (*)
SELECT
![Page 167: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/167.jpg)
UPDATE (*)
95. 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?
Mark for Review
(1) Points
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
DELETE * FROM employees WHERE id_num = 348;
DELETE 'jones' FROM employees;
![Page 168: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/168.jpg)
Incorrect Incorrect. Refer to Section 7
96. 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?
Mark for Review
(1) Points
You need to display the start date for each class taught by a given teacher.
![Page 169: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/169.jpg)
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. (*)
Incorrect Incorrect. Refer to Section 7
96. 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)
![Page 170: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/170.jpg)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)
Which scenario would require a subquery to return the desired results?
Mark for Review
(1) Points
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. (*)
97. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
![Page 171: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/171.jpg)
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
![Page 172: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/172.jpg)
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
97. Examine the structures of the PRODUCTS and SUPPLIERS tables:
![Page 173: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/173.jpg)
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for
98. What would happen if you issued a DELETE statement without a WHERE clause? Mark
for Review
(1) Points
![Page 174: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/174.jpg)
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Incorrect Incorrect. Refer to Section 7
99. 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(9,2)
![Page 175: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/175.jpg)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee number 89898. Currently, all employees in department 10 have the
same salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employee
SET salary = SELECT salary
FROM employee
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
![Page 176: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/176.jpg)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
100. Which of the following represents the correct syntax for an INSERT statement? Mark
for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777');
(*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Test: Mid Term Exam - Database Programming with SQL
![Page 177: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/177.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
2. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
![Page 178: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/178.jpg)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Correct
3. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
![Page 179: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/179.jpg)
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
4. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
TRUNC
SUBSTR (*)
CONCAT
Correct
![Page 180: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/180.jpg)
5. You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
1
2
13 (*)
17
Correct
6. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
![Page 181: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/181.jpg)
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Correct
7. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employee;
![Page 182: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/182.jpg)
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEE table.
The email address of each employee in the EMPLOYEE table.
The number of characters for each value in the EMAIL column in the employees table. (*)
The maximum number of characters allowed in the EMAIL column.
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. Which two functions can be used to manipulate number or date column values, but NOT character
column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
![Page 183: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/183.jpg)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Correct
9. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employee;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employee;
![Page 184: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/184.jpg)
SELECT ROUND(hire_date, 'MON')
FROM employee;
SELECT TRUNC(hire_date, 'MI')
FROM employee;
Incorrect. Refer to Section 1 Lesson 3
10. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
![Page 185: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/185.jpg)
750 (*)
751
751.3
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Which SELECT statement will NOT return a date value? Mark for Review
(1) Points
![Page 186: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/186.jpg)
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
12. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
![Page 187: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/187.jpg)
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Correct
13. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Correct
![Page 188: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/188.jpg)
14. You need to display the current year as a character value (for example: Two Thousand and One).
Which element would you use? Mark for Review
(1) Points
RR
YY
YYYY
YEAR (*)
Correct
15. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
![Page 189: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/189.jpg)
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
![Page 190: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/190.jpg)
TO_NUMBER
CHARTOROWID
Correct
17. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an SQL statement's result
set.
The TO_CHAR function can be used to remove text from column data that will be returned by the
database.
The TO_CHAR function can be used to display dates and numbers according to formatting conventions
that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
Correct
![Page 191: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/191.jpg)
18. You have been asked to create a report that lists all customers who have placed orders of at least
$2,500. The report's date should be displayed in the Day, Date Month, Year format (For example,
Tuesday, 13 April, 2004 ). Which statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
![Page 192: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/192.jpg)
Incorrect. Refer to Section 2
19. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct
20. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
![Page 193: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/193.jpg)
Single row functions can be nested. (*)
Single row functions return one or more results per row.
Correct
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
![Page 194: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/194.jpg)
21. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
![Page 195: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/195.jpg)
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
![Page 196: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/196.jpg)
Correct
23. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles
WHERE style_name LIKE 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;
Which result will the query provide?
Mark for Review
![Page 197: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/197.jpg)
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
![Page 198: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/198.jpg)
STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
(*)
Correct
24. You need to replace null values in the DEPT_ID column with the text "N/A". Which functions should
you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Correct
![Page 199: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/199.jpg)
Section 3 Lesson 2
(Answer all questions in this section)
25. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
![Page 200: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/200.jpg)
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
Correct
26. What is produced when a join condition is not specified in a multiple-table query? Mark for
Review
(1) Points
a self-join
an outer join
an equijoin
a Cartesian product (*)
Correct
![Page 201: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/201.jpg)
27. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
28. Which statement about the join syntax of a SELECT statement is true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
![Page 202: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/202.jpg)
The WHERE clause represents the join criteria. (*)
Correct
29. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
![Page 203: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/203.jpg)
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
30. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
![Page 204: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/204.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
(*)
Correct
![Page 205: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/205.jpg)
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. 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 =
BETWEEN...AND... and IN
![Page 206: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/206.jpg)
IN and =
Correct
32. 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
33. Which of the following best describes the function of an outer join? Mark for Review
(1) Points
![Page 207: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/207.jpg)
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and the far right column in the
other table.
An outer join will return data only if both tables contain an identical pair of columns.
An outer join will return all rows that meet the join criteria and will return NULL values from one table
if no rows from the other table satisfy the join criteria. (*)
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table.
Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
![Page 208: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/208.jpg)
An inner join
A full outer join
Correct
35. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Correct
36. A join between tables where the result set includes matching values from both tables but does
NOT return any unmatched rows could be called which of the following? (Choose three) Mark for
Review
![Page 209: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/209.jpg)
(1) Points
(Choose all correct answers)
Equijoin (*)
Self join (*)
Nonequijoin
Simple join (*)
full outer join
Incorrect. Refer to Section 4
Section 4 Lesson 3
(Answer all questions in this section)
37. Evaluate this SELECT statement:
![Page 210: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/210.jpg)
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)
Correct
38. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
![Page 211: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/211.jpg)
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Correct
39. 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 (*)
![Page 212: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/212.jpg)
Correct
40. For which condition would you use an equijoin query with the USING keyword? Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of columns in
the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column in the PRODUCT
table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID column in the
ORDER table contains null values that need to be displayed.
Correct
Page 4 of 10
![Page 213: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/213.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. What should be included in a SELECT statement to return NULL values from all tables? Mark for
Review
(1) Points
natural joins
left outer joins
full outer joins (*)
right outer joins
Incorrect. Refer to Section 4
![Page 214: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/214.jpg)
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Correct
43. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
![Page 215: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/215.jpg)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Correct
Section 5 Lesson 1
(Answer all questions in this section)
![Page 216: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/216.jpg)
44. 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
45. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
![Page 217: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/217.jpg)
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
46. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
![Page 218: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/218.jpg)
Correct
47. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
four
two (*)
Group functions cannot be nested.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. Which group functions below act on character, number and date data types?
![Page 219: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/219.jpg)
(Choose more than one answer) Mark for Review
(1) Points
(Choose all correct answers)
SUM
MAX (*)
MIN (*)
AVG
COUNT (*)
Correct
49. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
![Page 220: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/220.jpg)
VAR_SAMP
VARIANCE
Correct
50. 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
![Page 221: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/221.jpg)
COUNT
STDDEV
Correct
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
![Page 222: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/222.jpg)
51. 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
52. Which group function would you use to display the highest salary value in the EMPLOYEE table?
Mark for Review
(1) Points
AVG
COUNT
MAX (*)
![Page 223: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/223.jpg)
MIN
Correct
53. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
![Page 224: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/224.jpg)
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
54. 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)
![Page 225: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/225.jpg)
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
55. Group functions return a value for ________________ and ________________ null values in their
computations. Mark for Review
(1) Points
a row set, ignore (*)
![Page 226: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/226.jpg)
each row, ignore
a row set, include
each row, include
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Which statement about the COUNT function is true? Mark for Review
(1) Points
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each column.
![Page 227: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/227.jpg)
The COUNT function can be used to determine the number of unique, non-null values in a column.
Incorrect. Refer to Section 5
57. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
![Page 228: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/228.jpg)
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Correct
58. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
![Page 229: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/229.jpg)
SELECT
UNLIKE
Correct
59. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
![Page 230: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/230.jpg)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Correct
Section 6 Lesson 1
(Answer all questions in this section)
60. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location. You need to include
only the products that have a price less than $25.00. The extended cost of each item equals the quantity
value multiplied by the cost value.
Which SQL statement will display the desired result?
![Page 231: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/231.jpg)
Mark for Review
(1) Points
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
![Page 232: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/232.jpg)
Incorrect. Refer to Section 6
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id
![Page 233: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/233.jpg)
FROM employee
GROUP BY dept_id;
How are the results of this statement sorted?
Mark for Review
(1) Points
Ascending order by dept_id (*)
Descending order by dept_id
Ascending order by cumulative salary
Descending order by cumulative salary
Correct
62. The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)
![Page 234: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/234.jpg)
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
63. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
![Page 235: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/235.jpg)
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Incorrect. Refer to Section 6
64. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
![Page 236: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/236.jpg)
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Incorrect. Refer to Section 6
![Page 237: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/237.jpg)
65. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section 6
66. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
![Page 238: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/238.jpg)
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Correct
67. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer made a payment
between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
![Page 239: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/239.jpg)
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Incorrect. Refer to Section 6
![Page 240: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/240.jpg)
Section 6 Lesson 2
(Answer all questions in this section)
68. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Correct
69. Which operator can be used with subqueries that return only one row? Mark for Review
(1) Points
LIKE (*)
![Page 241: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/241.jpg)
ANY
ALL
IN
Correct
70. If you use the equality operator (=) with a subquery, how many values can the subquery return?
Mark for Review
(1) Points
only 1 (*)
up to 2
up to 5
unlimited
Correct
![Page 242: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/242.jpg)
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. You need to display all the players whose salaries are greater than or equal to John Brown's salary.
Which comparison operator should you use? Mark for Review
(1) Points
=
>
<=
![Page 243: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/243.jpg)
>= (*)
Correct
72. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
![Page 244: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/244.jpg)
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. 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
![Page 245: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/245.jpg)
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
![Page 246: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/246.jpg)
WHERE last_name = 'Carter');
(*)
Correct
74. 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)
![Page 247: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/247.jpg)
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
75. 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
![Page 248: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/248.jpg)
a query that returns one or more column values from the inner SELECT statement
Correct
Section 6 Lesson 4
(Answer all questions in this section)
76. 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.
![Page 249: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/249.jpg)
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.
Correct
77. Which of the following best describes the meaning of the ANY operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Correct
![Page 250: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/250.jpg)
78. 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. (*)
Correct
![Page 251: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/251.jpg)
79. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
![Page 252: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/252.jpg)
Change the comparison operator to a single-row operator.
Correct
80. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
![Page 253: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/253.jpg)
Correct
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
![Page 254: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/254.jpg)
FROM teams
WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
Correct
82. 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);
![Page 255: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/255.jpg)
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
83. 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.
![Page 256: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/256.jpg)
Multiple-row subqueries can only be used in SELECT statements.
Correct
84. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct
85. Which statement about the ANY operator when used with a multiple-row subquery is true? Mark
for Review
(1) Points
![Page 257: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/257.jpg)
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
Correct
86. What would happen if you attempted to use a single-row operator with a multiple-row subquery?
Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Correct
![Page 258: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/258.jpg)
Section 7 Lesson 1
(Answer all questions in this section)
87. 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
Correct
88. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
![Page 259: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/259.jpg)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Correct
89. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
![Page 260: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/260.jpg)
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
![Page 261: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/261.jpg)
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Correct
90. 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
![Page 262: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/262.jpg)
Correct
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
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
![Page 263: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/263.jpg)
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct
92. 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? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Correct
![Page 264: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/264.jpg)
93. 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
94. 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(9,2)
BONUS NUMBER(9,2)
![Page 265: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/265.jpg)
You need to increase the salary for all employees in department 10 by 10 percent. You also need to
increase the bonus for all employees in department 10 by 15 percent. Which statement should you use?
Mark for Review
(1) Points
UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE dept = 10;
(*)
UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE dept = 10;
UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE dept = 10;
UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE dept = 10;
![Page 266: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/266.jpg)
Incorrect. Refer to Section 7
95. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
![Page 267: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/267.jpg)
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
96. What would happen if you issued a DELETE statement without a WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
![Page 268: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/268.jpg)
Only one row would be deleted.
Correct
97. Which of the following represents the correct syntax for an INSERT statement? Mark for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Correct
98. The PLAYERS table contains these columns:
PLAYER_ID NUMBER NOT NULL
PLAYER_LNAME VARCHAR2(20) NOT NULL
PLAYER_FNAME VARCHAR2(10) NOT NULL
![Page 269: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/269.jpg)
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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
99. You need to update the expiration date of products manufactured before June 30th . In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
![Page 270: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/270.jpg)
the WHERE clause (*)
the SET clause
the USING clause
Correct
100. 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?
Mark for Review
(1) Points
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
![Page 271: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/271.jpg)
DELETE * FROM employees WHERE id_num = 348;
DELETE 'jones' FROM employees;
Correct
Page 10 of 10
1. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
![Page 272: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/272.jpg)
Correct
2. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Correct
You query the database with this SQL statement:
![Page 273: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/273.jpg)
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
4. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
![Page 274: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/274.jpg)
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 11.00
You query the database and return the value 40. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
(*)
![Page 275: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/275.jpg)
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
Correct
You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
1
2
13 (*)
![Page 276: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/276.jpg)
17
Correct
6. You need to display the number of characters in each customer's last name. Which function should
you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct
7. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
![Page 277: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/277.jpg)
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Correct
. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
![Page 278: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/278.jpg)
(1) Points
1200
1282
1282.25
1300 (*)
Correct
9. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
1 (*)
2
25
0
![Page 279: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/279.jpg)
Correct
10. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Incorrect. Refer to Section 1 Lesson 1
11. Which function would you use to return the current database server date and time? Mark for
Review
(1) Points
DATE
SYSDATE (*)
DATETIME
![Page 280: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/280.jpg)
CURRENTDATE
Correct
12. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Correct
13. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
![Page 281: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/281.jpg)
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
14. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
15. Evaluate this SELECT statement:
![Page 282: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/282.jpg)
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
Incorrect. Refer to Section 1
16. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
![Page 283: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/283.jpg)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct
17. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Incorrect. Refer to Section 2
18. The EMPLOYEES table contains these columns:
![Page 284: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/284.jpg)
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;
SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
FROM employees;
(*)
![Page 285: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/285.jpg)
SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
Incorrect. Refer to Section 2
19. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
![Page 286: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/286.jpg)
Incorrect. Refer to Section 2
20. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
![Page 287: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/287.jpg)
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Incorrect. Refer to Section 2
21. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
![Page 288: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/288.jpg)
22. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Correct
23. When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null? Mark for Review
(1) Points
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
![Page 289: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/289.jpg)
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
FROM student_accounts;
Incorrect. Refer to Section 2
24. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
![Page 290: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/290.jpg)
Correct
25. 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
26. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
![Page 291: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/291.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
(*)
Correct
27. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
![Page 292: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/292.jpg)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
![Page 293: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/293.jpg)
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
28. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
![Page 294: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/294.jpg)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
Correct
29. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
![Page 295: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/295.jpg)
Incorrect. Refer to Section
30. Which statement about the join syntax of a SELECT statement is true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Incorrect. Refer to Section 3
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. (*)
![Page 296: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/296.jpg)
Outer joins are always evaluated before other types of joins in the query.
Correct
32. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
![Page 297: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/297.jpg)
Correct
33. 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 =
BETWEEN...AND... and IN
IN and =
Incorrect. Refer to Section 3
34. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
![Page 298: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/298.jpg)
Columns with the same names cannot be included in the SELECT list of the query.
Incorrect. Refer to Section 4
35. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table.
Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
36. 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
![Page 299: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/299.jpg)
A join between tables where matching fields do not exist
A join that uses only one table
Correct
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 (*)
Correct
38. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
![Page 300: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/300.jpg)
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Incorrect. Refer to Section 4
39. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in
sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
![Page 301: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/301.jpg)
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about orders placed by
customers who reside in Nashville . Which query should you issue to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
![Page 302: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/302.jpg)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Correct
40. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
![Page 303: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/303.jpg)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
![Page 304: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/304.jpg)
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Incorrect. Refer to Section 4
41. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
![Page 305: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/305.jpg)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
![Page 306: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/306.jpg)
Incorrect. Refer to Section 4
43. What should be included in a SELECT statement to return NULL values from all tables? Mark for
Review
(1) Points
natural joins
left outer joins
full outer joins (*)
right outer joins
Incorrect. Refer to Section 4
44. If a select list contains both a column as well as a group function then what clause is required?
Mark for Review
(1) Points
having clause
join clause
![Page 307: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/307.jpg)
order by clause
group by clause (*)
Incorrect. Refer to Section 5
45. Evaluate this SELECT statement:
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
![Page 308: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/308.jpg)
Incorrect. Refer to Section 5
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.
Incorrect. Refer to Section 5
47. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
![Page 309: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/309.jpg)
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Incorrect. Refer to Section 5
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
49. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
![Page 310: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/310.jpg)
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
![Page 311: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/311.jpg)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
50. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect. Refer to Section 5
51. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
![Page 312: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/312.jpg)
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect. Refer to Section 5
52. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
Mark for Review
(1) Points
![Page 313: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/313.jpg)
AVG
COUNT
MAX
MIN (*)
Incorrect. Refer to Section 5
53. You need to calculate the average salary of employees in each department. Which group function
will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
Correct
![Page 314: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/314.jpg)
54. 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
55. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
![Page 315: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/315.jpg)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Incorrect. Refer to Section 5
56. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
![Page 316: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/316.jpg)
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
![Page 317: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/317.jpg)
Incorrect. Refer to Section 5
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
![Page 318: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/318.jpg)
Incorrect. Refer to Section 5
58. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
SELECT
UNLIKE
Incorrect. Refer to Section 5
59. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM products;
Which statement is true?
Mark for Review
(1) Points
![Page 319: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/319.jpg)
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.
An error occurs because no WHERE clause is included in the SELECT statement.
Incorrect. Refer to Section 5
60. 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)
![Page 320: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/320.jpg)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Incorrect. Refer to Section 6
61. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
![Page 321: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/321.jpg)
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Correct
62. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
![Page 322: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/322.jpg)
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
![Page 323: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/323.jpg)
HAVING
ORDER BY
GROUP BY
Correct
63. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
![Page 324: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/324.jpg)
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
64. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
![Page 325: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/325.jpg)
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Correct
65. Evaluate this SELECT statement:
![Page 326: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/326.jpg)
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section
66. 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
![Page 327: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/327.jpg)
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;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
![Page 328: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/328.jpg)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
(*)
Incorrect. Refer to Section 6
67. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
![Page 329: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/329.jpg)
Incorrect. Refer to Section 6
68. Using a subquery in which clause will return a syntax error? Mark for Review
(1) Points
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
Incorrect. Refer to Section 6
69. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
![Page 330: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/330.jpg)
The result of the main query is used with the subquery
Correct
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
![Page 331: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/331.jpg)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
![Page 332: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/332.jpg)
Incorrect. Refer to Section 6
71. The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES
EMP_ID NUMBER(10) NOT NULL PRIMARY KEY
FNAME VARCHAR2(30)
LNAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMP_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin
during the year 2001?
Mark for Review
![Page 333: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/333.jpg)
(1) Points
SELECT order_id, total
FROM ORDERS (SELECT emp_id FROM employees WHERE lname = 'Franklin')
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT (SELECT emp_id FROM employees WHERE lname = 'Franklin') AND order_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT order_id, emp_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE emp_id = (SELECT emp_id FROM employees WHERE lname = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
![Page 334: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/334.jpg)
Correct
72. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
![Page 335: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/335.jpg)
You need to display all the orders that were placed on the same day as order number 25950. (*)
Incorrect. Refer to Section 6
73. 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');
![Page 336: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/336.jpg)
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
74. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
![Page 337: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/337.jpg)
no rows (*)
all the rows in the table
a null value
an error
Incorrect. Refer to Section 6
75. 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
Incorrect. Refer to Section 6
![Page 338: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/338.jpg)
76. 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
Incorrect. Refer to Section 6
77. 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);
![Page 339: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/339.jpg)
SELECT description
FROM d_types
WHERE code <> ALL (SELECT type_code FROM d_songs);
All of the above. (*)
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.
![Page 340: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/340.jpg)
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. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Incorrect. Refer to Section 6
80. Which of the following best describes the meaning of the ANY operator? Mark for Review
![Page 341: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/341.jpg)
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Correct
81. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review
(1) Points
ALL
ANY
= (*)
>
![Page 342: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/342.jpg)
Incorrect. Refer
82. What would happen if you attempted to use a single-row operator with a multiple-row subquery?
Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Incorrect. Refer to Section 6
83. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
![Page 343: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/343.jpg)
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
![Page 344: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/344.jpg)
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
![Page 345: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/345.jpg)
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Incorrect. Refer to Section 6
86. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
![Page 346: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/346.jpg)
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Incorrect. Refer to Section 6
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)
![Page 347: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/347.jpg)
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
Incorrect. Refer to Section 7
88. You need to add a row to an existing table. Which DML statement should you use? Mark for
Review
(1) Points
UPDATE
INSERT (*)
DELETE
![Page 348: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/348.jpg)
CREATE
Incorrect. Refer
89. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
![Page 349: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/349.jpg)
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Incorrect. Refer to Section 7
90. 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
Correct
91. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
![Page 350: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/350.jpg)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
![Page 351: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/351.jpg)
SET cooper = 'lname'
WHERE lname = 'roper';
Incorrect. Refer to Section 7
92. 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
Correct
93. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
![Page 352: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/352.jpg)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
![Page 353: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/353.jpg)
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Correct
94. 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(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee number 89898. Currently, all employees in department 10 have the
same salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employee
SET salary = SELECT salary
FROM employee
![Page 354: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/354.jpg)
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
Incorrect. Refer to Section 7
95. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
![Page 355: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/355.jpg)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Incorrect. Refer to Section 7
96. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
97. The PLAYERS table contains these columns:
![Page 356: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/356.jpg)
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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
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)
![Page 357: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/357.jpg)
FNAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
Mark for Review
(1) Points
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
DELETE * FROM employees WHERE id_num = 348;
DELETE 'jones' FROM employees;
Correct
99. You need to update the expiration date of products manufactured before June 30th . In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
![Page 358: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/358.jpg)
the SET clause
the USING clause
Correct
100. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table
using one UPDATE statement. Which clause should you include in the UPDATE statement to update
multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Correct
![Page 359: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/359.jpg)
1. Once you have learned how to write programs and build systems, you no longer need any input or involvement from any users, as you are perfectly capable of delivering the systems the business needs and wants.
- True. All that perfect systems need are correct programs. - False. Business requirements can and will change. For instance new legal
requirements may arise. (*) - True. All users do is delay systems delivery with their forever changing minds and new
requirements. - True. Users never know what they want anyway, so building systems are best left to the
professionals. 2. Information which was gained from data is the same as: (Choose Two)
- Knowledge (*) - Raw Materials - Intelligence (*) - There is no difference between data and information
3. Consider your school library. It will have a database with transaction details of which student borrows which books. Is details of the total number of books out on loan in one given month Data or Information?
- Data - Information (*) - Both - Neither
4. The first step in system development is to document the requirements. Why? - Wrong. A blueprint for the database design is not needed. We can just start coding
straight away
- It clarifies what a business wants to accomplish, and provides measures for deciding if the system delivers all that is required. (*)
- It allows application development to be conducted without having to consider database design.
- It keeps businesses honest 5. Databases were invented in 1989. True or False?
- True
- False (*) 6. Oracle Database Software do not provide or does not comprise of which functionality?
- Graphical User Interface
- Internet Browser - Server - Operating System (*)
7. An entity is instantiated as a ? - experience
- instance - table (*) - none of the above
![Page 360: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/360.jpg)
8. Relationship names are usually verbs. True or False? - True (*)
- False 9. The entity/relationship model is created before the physical database design model. True or
False? - True (*)
- False 10. All of the following could be attributes of an ENTITY called PERSON except one. Select the
incorrect one: - Haircolor
- Weight - Gender - Natacha Hansen (*)
11. An entity can have many Unique Identifiers. True or False? - True (*)
- False 12. Volatile entities have special requirements and need special attention when you are doing data
modelling. True or False? - True (*)
- False 13. Which of the following entities most likely contains valid attributes?
- Entity: Home. Attributes: Number of Bedrooms, Owner, Address, Date Built (*) - Entity: Pet. Attributes: Name, Birthdate, Owner (*) - Entity: Car. Attributes: Owner Occupation, Owner Salary, Speed - Entity: Mother. Attributes: Name, Birthdate, Occupation, Salary
14. Relationship Names are optional. True or False? - True - False (*)
15. Which of the following are valid relationship degrees - 1:1 (*) - 1:M (*) - 1:O - O:O
16. Which symbol is used to show that a particular attribute is mandatory? - * (*) - O - # - &
17. The many end of a Relationship is called: - Gulls Foot - Pigs Ear - Crows Ear - Crows Foot (*)
18. When reading a relationship between 2 entities, the relationship is read both from left to right and right to left. True or False?
- True (*) - False
19. All ER diagrams must have one of each of the following: - One or more Entities (*) - Relationships between entities (*) - Arcs - At least one supertype and subtype
20. Which of the following are suitable Entity names? (Choose Two) - DOGS
![Page 361: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/361.jpg)
- ANIMAL (*) - ANIMALS - DOG (*)
21. Which of the following is true about subtypes? - One instance may belong to two subtypes of the same supertype. - Subtypes must be mutually exclusive. (*) - Subtypes must not be mutually exclusive. - Subtype entities may not have relationships to the other subtype entities, only the
supertype itself. 22. All instances of the supertype must be an instance of one of the subtypes. True or False?
- True (*) - False
23. All instances of the subtypes can be an instance of the supertype but do not have to. True or False?
- True - False (*)
24. How would you model a business rule that states that girls and boys may not attend classes together?
- Use a supertype - Use two subtypes with relationships from class to student gender (*) - Make the attribute Gender mandatory - You cannot model this. You need to document it.
25. Can all constraints be modeled on an ER diagram? - No, in which case you should let the database administrator handle them - No, but you just explain them to the users so they can enforce them - Yes, all constraints must be modeled and shown on the ER diagram - No, so you should list them on a separate document to be handled
programmatically (*) 26. Business rules are not important to data modelers. True or False?
- True - False (*)
27. Why is it important to identify and document structural rules? - Ensures we know what data to store and how that data interrelate. (*) - Ensures nothing. There is no benefits to be gained from documenting your Structural
Business Rules. We need to concentrate on the Procedural Business Rules only. - Ensures we know what Information to store and how that Information interrelate. - All of the Above.
28. A non-transferable relationship means the detail cannot be changed to point to a new master. True or False?
- True (*) - False
29. If two entities have two relationships between them, these relationships can be either _____________ or _____________ ? (Choose Two)
- Redundant or Required (In which case they would depict different relationships) (*) - Replicated or Required (In which case they would depict different relationships) - Resourced and Really Good - Redundant and Replicated
30. What uncommon relationship is described by the statements: "Each DNA SAMPLE may be taken from one and only one PERSON and each PERSON may provide one and only one DNA SAMPLE"
- One to Many Optional - One to Many Mandatory - One to One Optional (*) - Many to Many Mandatory
31. How do you include a relationship as part of the UID for an entity? - By barring the relationship in question (*)
![Page 362: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/362.jpg)
- By reporting it in an external document - By including the UID from the parent entity as an attribute in the entity - You cannot model that.
32. Many to many relationships must be left in the Model. It is important to have them documented as M-M. True or False?
- True - False (*)
33. The first UID for an entity is called the Primary UID, the second is called Secondary UID and so on.
- Yes, this is the way UID's are named. (*)
- No, it is not possible to have more than one UID for an Entity. - Yes, but then it stops. No entities can have more than two UID's. - No, each Entity can only have one UID, the secondary one.
34. When data is stored in one place in a database, the database conforms to the rules of - Normality - Reduction - Normalization (*) - Multiplication
35. When is an entity in 2nd Normal Form? - When all non-UID attributes are dependent upon the entire UID. (*) - When no attritibutes are mutually independant and fully independent on the primary key. - When no attritibutes are mutually independent and all are fully dependent on the primary
key. - None of the Above.
36. No parts of a UID are mandatory. True or False? - True
- False (*) 37. Which of the following is NOT a relationship type?
- Some to None (*)
- One to One - One to Many - Many to Many
38. All relationships participating in an arc must be mandatory. True or False? - True
- False (*) 39. Which of the following would best be represented by an arc?
- STUDENT (Female, Bob)
- DELIVERY ADDRESS ( Home, Office) (*) - PARENT (Girl, Bob) - STUDENT (Grade A student, Average Student)
40. Arcs are Mandatory in Data modelling. All ERD's must have at least one Arc. True or False? - True
- False (*) 41. Which of the following would be good as a Unique Identifier for its Entity?
- Personal Identification number for Person (*)
- Vehicle Registration Number for Car (*) - ISBN Number for Book (*) - Date of birth for Baby
42. Modeling historical data can produce a unique identifier that always excludes dates. True or False?
- True - False (*)
![Page 363: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/363.jpg)
43. Consultants often use their experience in ensuring projects stay on track and delivers within the timescales set out for the project. True or False?
- True (*) - False
44. Your apperance at a presentation is important. You need to look smart and presentable. True or False?
- True (*) - False
45. Which of the following would be a logical constraint when modeling time for a City entity? - People are born in the city and people die in the city. - Cites may change their name and/or which country they are placed in, if the
borders of a country change. (*) - If you are doing a system for any French City, you would need security clearance - You need a constant record of cities because they are still cities, even if leadership
changes over time, e.g. they get a new Mayor 46. If a system includes the concept of time, and it stores Start Dates, then End Dates becomes
Mandatory. For each Start Date attribute you create, you MUST create an End Date attribute and it must be mandatory. True or False?
- True - False (*)
47. Modeling historical data is Optional. True or False? - True (*) - False
48. What do users of a system without the concept of time loose? - Journalling becomes much easier. - Journalling becomes slightly harder. - The ability to track data over time. (*) - Nothing is lost if a system does not track time.
49. Why would you want to model a time component when designing a system that lets people buy shares via the Internet?
- This would only be required in the US to allow the New York Stock Exchange to be notified of this information.
- To allow the sales people to determine when the shared were bought and therefore at what price. (*)
- You would not want to model this, it is not important. - The price of shares fluctuates and for determining price, you need to know the
time of purchase (*) 50. You are doing a data model for a computer sales company, where the price of postage is
ependant on what day of the week goods are shipped. So shipping is more expensive if the customer wants a delivery to take place on a Saturday or Sunday. What would be the best way to model this?
- Use a Delivery Day entity, which holds prices against week days, and ensure the we also have an attribute for the Requested Delivery Day in the Order Entity. (*)
- Email current price to all employees whenever the prices change. - Update the prices in the system, print out the current prices when they change and pin
them on the company noticeboard - Allow them to enter whatever ever delivery charge they want.
![Page 364: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/364.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
![Page 365: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/365.jpg)
LOWER (*)
All three will be evaluated simultaneously.
Correct
2. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
TRUNC
SUBSTR (*)
CONCAT
Correct
3. Evaluate this SELECT statement:
![Page 366: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/366.jpg)
SELECT LENGTH(email)
FROM employees;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEES table.
The email address of each employee in the EMPLOYEES table.
The number of characters for each value in the EMAIL column in the EMPLOYEES table. (*)
The maximum number of characters allowed in the EMAIL column.
Correct
4. What will the following SQL statement display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
![Page 367: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/367.jpg)
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Incorrect. Refer to Section 1
5. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
![Page 368: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/368.jpg)
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
6. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
![Page 369: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/369.jpg)
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
![Page 370: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/370.jpg)
Correct
7. You need to display each employee's name in all uppercase letters. Which function should you use?
Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
Correct
Section 1 Lesson 2
(Answer all questions in this section)
![Page 371: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/371.jpg)
8. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Incorrect. Refer to Section 1 Lesson 1
9. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
![Page 372: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/372.jpg)
700
750 (*)
751
751.3
Correct
10. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
1 (*)
2
25
0
Correct
![Page 373: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/373.jpg)
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
![Page 374: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/374.jpg)
NEXT_MONTH
Correct
12. The EMPLOYEES 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 employees;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
DATE (*)
![Page 375: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/375.jpg)
NUMBER
DATETIME
INTEGER
Incorrect. Refer to Section 1
13. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
![Page 376: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/376.jpg)
14. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
![Page 377: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/377.jpg)
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Incorrect. Refer to Section 1
15. Which of the following SQL statements will correctly display the last name and the number of
weeks employed for all employees in department 90? Mark for Review
(1) Points
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
![Page 378: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/378.jpg)
WHERE department_id = 90;
SELECT last_name, (SYSDATE-hire_date)AS WEEK
FROM employees
WHERE department_id = 90;
Incorrect. Refer to Section 1
Section 2 Lesson 1
(Answer all questions in this section)
16. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
![Page 379: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/379.jpg)
1917
Correct
17. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
Incorrect. Refer to Section 2
![Page 380: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/380.jpg)
18. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Incorrect. Refer to Section 2
19. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
![Page 381: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/381.jpg)
SYSDATE + 30 / 24
Incorrect. Refer to Section 2
20. You have been asked to create a report that lists all customers who have placed orders of at least
$2,500. The report's date should be displayed in the Day, Date Month, Year format (For example,
Tuesday, 13 April, 2004 ). Which statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
![Page 382: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/382.jpg)
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
Incorrect. Refer to Section 2
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
![Page 383: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/383.jpg)
Section 2 Lesson 1
(Answer all questions in this section)
21. Which three statements concerning explicit data type conversions are true? (Choose three.) Mark
for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string. (*)
Incorrect. Refer to Section 2
Section 2 Lesson 2
![Page 384: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/384.jpg)
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Incorrect. Refer to Section 2
23. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
![Page 385: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/385.jpg)
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Correct
24. You need to replace null values in the DEPARTMENT_ID column with the text "N/A". Which
functions should you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
![Page 386: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/386.jpg)
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. 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
Incorrect. Refer to Section 3
![Page 387: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/387.jpg)
26. You need to provide a list of the first and last names of all employees who work in the Sales
department who earned a bonus and had sales over $50,000. The company president would like the
sales listed starting with the highest amount first. The EMPLOYEES table and the SALES_DEPT table
contain the following columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(8,2)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MANAGER NUMBER(10)
BONUS NUMBER(10)
EMPLOYEE_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
![Page 388: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/388.jpg)
WHERE e.employee_id = s.employee_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
WHERE e.employee_id = s.employee_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
Incorrect. Refer to Section 3
![Page 389: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/389.jpg)
27. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Incorrect. Refer to Section 3
![Page 390: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/390.jpg)
28. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
![Page 391: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/391.jpg)
A syntax error
Incorrect. Refer to Section 3
29. What is produced when a join condition is not specified in a multiple-table query using Oracle
proprietary Join syntax? Mark for Review
(1) Points
a self-join
an outer join
an equijoin
a Cartesian product (*)
Incorrect. Refer to Section 3
30. What happens when you create a Cartesian product? Mark for Review
(1) Points
![Page 392: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/392.jpg)
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
![Page 393: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/393.jpg)
Section 3 Lesson 4
(Answer all questions in this section)
31. Using Oracle Proprietary join syntax, 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 =
BETWEEN...AND... and IN
IN and =
Correct
32. 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.
![Page 394: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/394.jpg)
The OR operator cannot be used to link outer join conditions. (*)
Outer joins are always evaluated before other types of joins in the query.
Incorrect. Refer to Section 3
33. Using Oracle Proprietary join syntax, 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
![Page 395: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/395.jpg)
Section 4 Lesson 2
(Answer all questions in this section)
34. You need to join two tables that have two columns with the same name, datatype and precision.
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
35. A join between tables where the result set includes matching values from both tables but does
NOT return any unmatched rows could be called which of the following? (Choose three) Mark for
Review
(1) Points
(Choose all correct answers)
![Page 396: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/396.jpg)
Equijoin (*)
Self join (*)
Nonequijoin
Simple join (*)
Full outer join
Incorrect. Refer to Section 4
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. (*)
![Page 397: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/397.jpg)
Correct
Section 4 Lesson 3
(Answer all questions in this section)
37. Which keyword in a SELECT statement 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. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
![Page 398: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/398.jpg)
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
![Page 399: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/399.jpg)
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
![Page 400: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/400.jpg)
Incorrect. Refer to Section 4
39. 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 don't have matching data types to be joined
Incorrect. Refer to Section 4
40. Evaluate this SELECT statement:
SELECT a.last_name || ', ' || a.first_name as "Patient", b.last_name || ', ' || b.first_name as "Physician",
c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id)
JOIN admission c
![Page 401: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/401.jpg)
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
Page 4 of 10
![Page 402: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/402.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. Which query represents the correct syntax for a left outer join? Mark for Review
(1) Points
SELECT companyname, orderdate, total
FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
![Page 403: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/403.jpg)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
![Page 404: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/404.jpg)
OUTER JOIN and USING
Incorrect. Refer to Section 4
43. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which
type of join would you use? Mark for Review
(1) Points
a right outer join
a left outer join
a full outer join (*)
an inner join
Incorrect. Refer to Section 4
Section 5 Lesson 1
![Page 405: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/405.jpg)
(Answer all questions in this section)
44. Evaluate this SELECT statement:
SELECT MAX(salary), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Correct
45. Evaluate this SELECT statement:
![Page 406: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/406.jpg)
SELECT MIN(hire_date), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEES table.
The latest hire date in the EMPLOYEES table.
The hire dates in the EMPLOYEES table that contain NULL values.
Incorrect. Refer to Section 5
46. If a select list contains both columns as well as groups function then what clause is required? Mark
for Review
(1) Points
having clause
![Page 407: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/407.jpg)
join clause
order by clause
group by clause (*)
Incorrect. Refer to Section 5
47. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
four
two (*)
Group functions cannot be nested.
Incorrect. Refer to Section 5
![Page 408: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/408.jpg)
Section 5 Lesson 2
(Answer all questions in this section)
48. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect. Refer to Section 5
49. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
![Page 409: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/409.jpg)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model = '4x4';
Correct
50. 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 (*)
![Page 410: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/410.jpg)
VARIANCE
COUNT
Correct
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
![Page 411: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/411.jpg)
51. Which aggregate function can be used on a column of the DATE data type? Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Incorrect. Refer to Section 5
52. 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
![Page 412: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/412.jpg)
Correct
53. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
![Page 413: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/413.jpg)
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Incorrect. Refer to Section 5
54. 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
55. The CUSTOMERS table contains these columns:
CUSTOMER_ID NUMBER(9)
![Page 414: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/414.jpg)
FIRST_NAME VARCHAR2(25)
LAST_NAME 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
Incorrect. Refer to Section 5
Section 5 Lesson 3
![Page 415: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/415.jpg)
(Answer all questions in this section)
56. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employees
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 EMPLOYEES table that have a salary greater than 30000. (*)
The query generates an error and returns no results.
Correct
57. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
![Page 416: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/416.jpg)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
![Page 417: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/417.jpg)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Incorrect. Refer to Section 5
58. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
Mark for Review
(1) Points
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT column is
not null. (*)
![Page 418: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/418.jpg)
Incorrect. Refer to Section 5
59. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for
Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
![Page 419: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/419.jpg)
60. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Incorrect. Refer to Section 6
Page 6 of 10
![Page 420: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/420.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you should use a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
![Page 421: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/421.jpg)
Correct
62. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer made a payment
between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
![Page 422: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/422.jpg)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Incorrect. Refer to Section 6
63. Evaluate this SELECT statement:
SELECT COUNT(emp_id), mgr_id, dept_id
FROM employee
WHERE status = 'I'
GROUP BY dept_id
HAVING salary > 30000
ORDER BY 2;
Why does this statement return a syntax error?
Mark for Review
(1) Points
![Page 423: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/423.jpg)
MGR_ID must be included in the GROUP BY clause. (*)
The HAVING clause must specify an aggregate function.
A single query cannot contain a WHERE clause and a HAVING clause.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
Incorrect. Refer to Section 6
64. Evaluate this SELECT statement:
SELECT COUNT(employee_id), department_id
FROM employees
GROUP BY department_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
![Page 424: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/424.jpg)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Incorrect. Refer to Section 6
65. 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) (*)
![Page 425: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/425.jpg)
GROUP BY MAX(salary)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Incorrect. Refer to Section 6
66. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, hire_date, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
![Page 426: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/426.jpg)
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect. Refer to Section 6
67. 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;
![Page 427: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/427.jpg)
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. Which statement about subqueries is true? Mark for Review
![Page 428: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/428.jpg)
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Incorrect. Refer to Section 6
69. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
=
LIKE
![Page 429: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/429.jpg)
Incorrect. Refer to Section 6
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
![Page 430: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/430.jpg)
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
![Page 431: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/431.jpg)
Incorrect. Refer to Section 6
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. Using a subquery in which of the following clauses will return a syntax error? Mark for Review
(1) Points
WHERE
![Page 432: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/432.jpg)
FROM
HAVING
You can use subqueries in all of the above clauses. (*)
Correct
72. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
![Page 433: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/433.jpg)
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Incorrect. Refer to Section 6
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
no rows (*)
![Page 434: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/434.jpg)
all the rows in the table
a null value
an error
Incorrect. Refer to Section 6
74. 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)
![Page 435: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/435.jpg)
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
75. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
![Page 436: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/436.jpg)
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row. (*)
Incorrect. Refer to Section 6
Section 6 Lesson 4
(Answer all questions in this section)
76. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
![Page 437: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/437.jpg)
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
Correct
77. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
![Page 438: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/438.jpg)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE old_dept_id = 15) AND new_dept_id = 10;
(*)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE old_dept_id = 15);
![Page 439: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/439.jpg)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) =
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE new_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, dept_id
FROM employee
WHERE old_dept_id = 15);
Incorrect. Refer to Section 6
78. 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
![Page 440: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/440.jpg)
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
79. Evaluate this SELECT statement:
SELECT customer_id, name
FROM customer
WHERE customer_id IN
(SELECT customer_id
![Page 441: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/441.jpg)
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
80. 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.
![Page 442: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/442.jpg)
Multiple-row subqueries can be used with both single-row and multiple-row operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
![Page 443: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/443.jpg)
81. 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
82. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
![Page 444: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/444.jpg)
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Correct
83. 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
First subquery not enclosed in parenthesis
![Page 445: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/445.jpg)
Single rather than multiple value operator used. (*)
Second subquery found on the right instead of the left side of the operator.
The greater than operator is not valid.
Incorrect. Refer to Section 6
84. 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.
![Page 446: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/446.jpg)
Both the inner and outer queries must return a value, or an error occurs.
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
![Page 447: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/447.jpg)
Incorrect. Refer to Section 6
86. You are looking for Executive information using a subquery. What will the following SQL statement
display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the Executive
department.
The department ID, last name, department name for every Executive in the employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive department. (*)
Correct
![Page 448: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/448.jpg)
Section 7 Lesson 1
(Answer all questions in this section)
87. 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
![Page 449: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/449.jpg)
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.
Incorrect. Refer to Section 7
88. 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
![Page 450: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/450.jpg)
Correct
89. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
![Page 451: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/451.jpg)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Incorrect. Refer to Section 7
90. 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
![Page 452: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/452.jpg)
70 will be inserted into the department_id column (*)
'Public Relations' will be inserted into the manager_name column
Correct
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
![Page 453: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/453.jpg)
91. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
![Page 454: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/454.jpg)
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
Correct
92. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
![Page 455: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/455.jpg)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Incorrect. Refer to Section 7
![Page 456: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/456.jpg)
93. 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
Incorrect. Refer to Section 7
94. 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? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
![Page 457: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/457.jpg)
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Incorrect. Refer to Section 7
95. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Incorrect. Refer to Section 7
96. Which two commands can be used to modify existing data in a database row? Mark for Review
(1) Points
(Choose all correct answers)
![Page 458: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/458.jpg)
DELETE
MERGE (*)
SELECT
UPDATE (*)
Incorrect. Refer to Section 7
97. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
![Page 459: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/459.jpg)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
![Page 460: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/460.jpg)
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id <
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
Correct
98. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
![Page 461: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/461.jpg)
Nothing. The statement will not execute.
Incorrect. Refer to Section 7
99. 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?
Mark for Review
(1) Points
![Page 462: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/462.jpg)
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. (*)
Incorrect. Refer to Section 7
100. 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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
![Page 463: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/463.jpg)
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Incorrect. Refer to Section 7
Page 10 of 10
1. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
![Page 464: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/464.jpg)
Correct
2. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Correct
You query the database with this SQL statement:
![Page 465: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/465.jpg)
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
4. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
![Page 466: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/466.jpg)
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 11.00
You query the database and return the value 40. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
(*)
![Page 467: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/467.jpg)
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
Correct
You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
1
2
13 (*)
![Page 468: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/468.jpg)
17
Correct
6. You need to display the number of characters in each customer's last name. Which function should
you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct
7. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
![Page 469: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/469.jpg)
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Correct
. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
![Page 470: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/470.jpg)
(1) Points
1200
1282
1282.25
1300 (*)
Correct
9. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
1 (*)
2
25
0
![Page 471: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/471.jpg)
Correct
10. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Incorrect. Refer to Section 1 Lesson 1
11. Which function would you use to return the current database server date and time? Mark for
Review
(1) Points
DATE
SYSDATE (*)
DATETIME
![Page 472: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/472.jpg)
CURRENTDATE
Correct
12. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Correct
13. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
![Page 473: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/473.jpg)
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
14. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
15. Evaluate this SELECT statement:
![Page 474: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/474.jpg)
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
Incorrect. Refer to Section 1
16. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
![Page 475: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/475.jpg)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct
17. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Incorrect. Refer to Section 2
18. The EMPLOYEES table contains these columns:
![Page 476: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/476.jpg)
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;
SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
FROM employees;
(*)
![Page 477: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/477.jpg)
SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
Incorrect. Refer to Section 2
19. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
![Page 478: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/478.jpg)
Incorrect. Refer to Section 2
20. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
![Page 479: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/479.jpg)
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Incorrect. Refer to Section 2
21. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
![Page 480: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/480.jpg)
22. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Correct
23. When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null? Mark for Review
(1) Points
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
![Page 481: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/481.jpg)
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
FROM student_accounts;
Incorrect. Refer to Section 2
24. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
![Page 482: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/482.jpg)
Correct
25. 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
26. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
![Page 483: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/483.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
(*)
Correct
27. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
![Page 484: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/484.jpg)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
![Page 485: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/485.jpg)
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
28. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
![Page 486: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/486.jpg)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
Correct
29. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
![Page 487: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/487.jpg)
Incorrect. Refer to Section
30. Which statement about the join syntax of a SELECT statement is true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Incorrect. Refer to Section 3
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. (*)
![Page 488: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/488.jpg)
Outer joins are always evaluated before other types of joins in the query.
Correct
32. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
![Page 489: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/489.jpg)
Correct
33. 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 =
BETWEEN...AND... and IN
IN and =
Incorrect. Refer to Section 3
34. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
![Page 490: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/490.jpg)
Columns with the same names cannot be included in the SELECT list of the query.
Incorrect. Refer to Section 4
35. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table.
Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
36. 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
![Page 491: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/491.jpg)
A join between tables where matching fields do not exist
A join that uses only one table
Correct
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 (*)
Correct
38. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
![Page 492: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/492.jpg)
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Incorrect. Refer to Section 4
39. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in
sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
![Page 493: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/493.jpg)
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about orders placed by
customers who reside in Nashville . Which query should you issue to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
![Page 494: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/494.jpg)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Correct
40. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
![Page 495: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/495.jpg)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
![Page 496: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/496.jpg)
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Incorrect. Refer to Section 4
41. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
![Page 497: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/497.jpg)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
![Page 498: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/498.jpg)
Incorrect. Refer to Section 4
43. What should be included in a SELECT statement to return NULL values from all tables? Mark for
Review
(1) Points
natural joins
left outer joins
full outer joins (*)
right outer joins
Incorrect. Refer to Section 4
44. If a select list contains both a column as well as a group function then what clause is required?
Mark for Review
(1) Points
having clause
join clause
![Page 499: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/499.jpg)
order by clause
group by clause (*)
Incorrect. Refer to Section 5
45. Evaluate this SELECT statement:
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
![Page 500: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/500.jpg)
Incorrect. Refer to Section 5
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.
Incorrect. Refer to Section 5
47. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
![Page 501: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/501.jpg)
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Incorrect. Refer to Section 5
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
49. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
![Page 502: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/502.jpg)
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
![Page 503: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/503.jpg)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
50. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect. Refer to Section 5
51. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
![Page 504: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/504.jpg)
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect. Refer to Section 5
52. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
Mark for Review
(1) Points
![Page 505: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/505.jpg)
AVG
COUNT
MAX
MIN (*)
Incorrect. Refer to Section 5
53. You need to calculate the average salary of employees in each department. Which group function
will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
Correct
![Page 506: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/506.jpg)
54. 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
55. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
![Page 507: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/507.jpg)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Incorrect. Refer to Section 5
56. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
![Page 508: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/508.jpg)
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
![Page 509: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/509.jpg)
Incorrect. Refer to Section 5
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
![Page 510: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/510.jpg)
Incorrect. Refer to Section 5
58. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
SELECT
UNLIKE
Incorrect. Refer to Section 5
59. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM products;
Which statement is true?
Mark for Review
(1) Points
![Page 511: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/511.jpg)
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.
An error occurs because no WHERE clause is included in the SELECT statement.
Incorrect. Refer to Section 5
60. 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)
![Page 512: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/512.jpg)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Incorrect. Refer to Section 6
61. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
![Page 513: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/513.jpg)
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Correct
62. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
![Page 514: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/514.jpg)
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
![Page 515: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/515.jpg)
HAVING
ORDER BY
GROUP BY
Correct
63. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
![Page 516: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/516.jpg)
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
64. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
![Page 517: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/517.jpg)
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Correct
65. Evaluate this SELECT statement:
![Page 518: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/518.jpg)
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section
66. 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
![Page 519: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/519.jpg)
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;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
![Page 520: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/520.jpg)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
(*)
Incorrect. Refer to Section 6
67. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
![Page 521: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/521.jpg)
Incorrect. Refer to Section 6
68. Using a subquery in which clause will return a syntax error? Mark for Review
(1) Points
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
Incorrect. Refer to Section 6
69. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
![Page 522: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/522.jpg)
The result of the main query is used with the subquery
Correct
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
![Page 523: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/523.jpg)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
![Page 524: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/524.jpg)
Incorrect. Refer to Section 6
71. The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES
EMP_ID NUMBER(10) NOT NULL PRIMARY KEY
FNAME VARCHAR2(30)
LNAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMP_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin
during the year 2001?
Mark for Review
![Page 525: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/525.jpg)
(1) Points
SELECT order_id, total
FROM ORDERS (SELECT emp_id FROM employees WHERE lname = 'Franklin')
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT (SELECT emp_id FROM employees WHERE lname = 'Franklin') AND order_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT order_id, emp_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE emp_id = (SELECT emp_id FROM employees WHERE lname = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
![Page 526: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/526.jpg)
Correct
72. the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
![Page 527: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/527.jpg)
You need to display all the orders that were placed on the same day as order number 25950. (*)
Incorrect. Refer to Section 6
73. 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');
![Page 528: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/528.jpg)
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
74. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
![Page 529: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/529.jpg)
no rows (*)
all the rows in the table
a null value
an error
Incorrect. Refer to Section 6
75. 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
Incorrect. Refer to Section 6
![Page 530: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/530.jpg)
76. 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
Incorrect. Refer to Section 6
77. 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);
![Page 531: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/531.jpg)
SELECT description
FROM d_types
WHERE code <> ALL (SELECT type_code FROM d_songs);
All of the above. (*)
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.
![Page 532: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/532.jpg)
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. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Incorrect. Refer to Section 6
80. Which of the following best describes the meaning of the ANY operator? Mark for Review
![Page 533: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/533.jpg)
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Correct
81. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review
(1) Points
ALL
ANY
= (*)
>
![Page 534: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/534.jpg)
Incorrect. Refer
82. What would happen if you attempted to use a single-row operator with a multiple-row subquery?
Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Incorrect. Refer to Section 6
83. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
![Page 535: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/535.jpg)
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
![Page 536: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/536.jpg)
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
![Page 537: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/537.jpg)
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Incorrect. Refer to Section 6
86. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
![Page 538: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/538.jpg)
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Incorrect. Refer to Section 6
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)
![Page 539: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/539.jpg)
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
Incorrect. Refer to Section 7
88. You need to add a row to an existing table. Which DML statement should you use? Mark for
Review
(1) Points
UPDATE
INSERT (*)
DELETE
![Page 540: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/540.jpg)
CREATE
Incorrect. Refer
89. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
![Page 541: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/541.jpg)
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Incorrect. Refer to Section 7
90. 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
Correct
91. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
![Page 542: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/542.jpg)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
![Page 543: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/543.jpg)
SET cooper = 'lname'
WHERE lname = 'roper';
Incorrect. Refer to Section 7
92. 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
Correct
93. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
![Page 544: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/544.jpg)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
![Page 545: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/545.jpg)
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Correct
94. 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(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee number 89898. Currently, all employees in department 10 have the
same salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employee
SET salary = SELECT salary
FROM employee
![Page 546: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/546.jpg)
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
Incorrect. Refer to Section 7
95. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
![Page 547: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/547.jpg)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Incorrect. Refer to Section 7
96. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
97. The PLAYERS table contains these columns:
![Page 548: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/548.jpg)
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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
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)
![Page 549: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/549.jpg)
FNAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
Mark for Review
(1) Points
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
DELETE * FROM employees WHERE id_num = 348;
DELETE 'jones' FROM employees;
Correct
99. You need to update the expiration date of products manufactured before June 30th . In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
![Page 550: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/550.jpg)
the SET clause
the USING clause
Correct
100. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table
using one UPDATE statement. Which clause should you include in the UPDATE statement to update
multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Correct
1. You need to display each employee's name in all uppercase letters. Which function should you use?
Mark for Review
(1) Points
![Page 551: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/551.jpg)
CASE
UCASE
UPPER (*)
TOUPPER
2. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
TRUNC
SUBSTR (*)
CONCAT
3. Evaluate this SELECT statement:
![Page 552: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/552.jpg)
SELECT LENGTH(email)
FROM employee;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEE table.
The email address of each employee in the EMPLOYEE table.
The number of characters for each value in the EMAIL column in the employees table. (*)
The maximum number of characters allowed in the EMAIL column.
4. You need to display the number of characters in each customer's last name. Which function
should you use? Mark for Review
(1) Points
LENGTH (*)
![Page 553: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/553.jpg)
LPAD
COUNT
SUBSTR
5. Which functions can be used to manipulate character, number, and date column values?
Mark for Review
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTH
6. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
![Page 554: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/554.jpg)
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
7. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
![Page 555: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/555.jpg)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
The SUBSTR character function returns a portion of a string beginning at a defined character
position to a specified length. (*)
![Page 556: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/556.jpg)
10. Which two functions can be used to manipulate number or date column values, but NOT
character column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
11. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
![Page 557: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/557.jpg)
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
12. You need to display the current year as a character value (for example: Two Thousand and One).
Which element would you use? Mark for Review
(1) Points
RR
YY
YYYY
![Page 558: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/558.jpg)
YEAR (*)
13. You need to display the number of months between today's date and each
employee's hiredate. Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
14. Which of the following SQL statements will correctly display the last name and the
number of weeks employed for all employees in department 90? Mark for Review
(1) Points
![Page 559: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/559.jpg)
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;
16. Which statement concerning single row functions is true? Mark for Review
![Page 560: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/560.jpg)
(1) Points
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
17. Which two statements concerning SQL functions are true? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
![Page 561: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/561.jpg)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
18. Which three statements concerning explicit data type conversions are true?
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
Use the TO_DATE function to convert a date value to character string or number.
![Page 562: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/562.jpg)
Use the TO_CHAR function to convert a number or date value to character string. (*)
19. 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;
SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
![Page 563: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/563.jpg)
FROM employees;
(*)
SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
20. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
![Page 564: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/564.jpg)
SYSDATE + 30 / 24
21. If you use the RR format when writing a query using the date 27-OCT-17 and the
year is 2001, what year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Incorrect Incorrect. Refer to Section 2
Previous Page 21 of 100 Next Summary
22. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
![Page 565: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/565.jpg)
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
23. Which of the following General Functions will return the first non-null expression in the
expression list? Mark for Review
(1) Points
NVL
![Page 566: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/566.jpg)
NVL2
NULLIF
COALESCE (*)
24. You need to replace null values in the DEPT_ID column with the text "N/A".
Which functions should you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
25. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
![Page 567: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/567.jpg)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Incorrect Incorrect. Refer to Section 3
26. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
![Page 568: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/568.jpg)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
27. When joining 3 tables in a SELECT statement, how many join conditions are needed in the
WHERE clause? Mark for Review
(1) Points
![Page 569: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/569.jpg)
0
1
2 (*)
3
Incorrect Incorrect. Refer to Section 3
28. You need to provide a list of the first and last names of all employees who work in the Sales
department who earned a bonus and had sales over $50,000. The company president would like the
sales listed starting with the highest amount first. The EMPLOYEES table and the SALES_DEPT table
contain the following columns:
EMPLOYEES
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
![Page 570: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/570.jpg)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MGR VARCHAR2(30)
BONUS NUMBER(10)
EMP_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.emp_id = s.emp_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000;
![Page 571: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/571.jpg)
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
WHERE e.emp_id = s.emp_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
29. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
![Page 572: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/572.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
(*)
30. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
![Page 573: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/573.jpg)
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
![Page 574: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/574.jpg)
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
31. The EMPLOYEE_ID column in the EMPLOYEE table corresponds to the EMPLOYEE_ID column of
the ORDER table. The EMPLOYEE_ID column in the ORDER table contains null values for rows that you
need to display.
Which type of join should you use to display the data? Mark for Review
(1) Points
natural join
self-join
outer join (*)
equijoin
32. Which statement about outer joins is true? Mark for Review
(1) Points
![Page 575: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/575.jpg)
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.
33. Which of the following best describes the function of an outer join? Mark
for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and the far right column
in the other table.
An outer join will return data only if both tables contain an identical pair of columns.
![Page 576: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/576.jpg)
An outer join will return all rows that meet the join criteria and will return NULL values from one
table if no rows from the other table satisfy the join criteria. (*)
34. 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. (*)
35. A join between tables where the result set includes matching values from both tables
but does NOT return any unmatched rows could be called which of the following? (Choose three)
Mark for Review
(1) Points
(Choose all correct answers)
![Page 577: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/577.jpg)
Equijoin (*)
Self join (*)
Nonequijoin
Simple join (*)
full outer join
36. 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
![Page 578: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/578.jpg)
Self-join
37. Which of the following statements is the simplest description of a nonequijoin? Mark
for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
38. 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);
![Page 579: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/579.jpg)
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)
39. 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
![Page 580: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/580.jpg)
It will display rows that do not meet the join condition
It permits columns with different names to be joined (*)
It permits columns that don't have matching data types to be joined
40. For which condition would you use an equijoin query with the USING keyword?
Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of
columns in the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column in the
PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID column
in the ORDER table contains null values that need to be displayed.
![Page 581: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/581.jpg)
41. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
![Page 582: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/582.jpg)
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
42. Which type of join returns rows from one table that have NO direct match in the other table?
Mark for Review
(1) Points
equijoin
self join
outer join (*)
natural join
43. What should be included in a SELECT statement to return NULL values from all tables?
Mark for Review
(1) Points
natural joins
![Page 583: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/583.jpg)
left outer joins
full outer joins (*)
right outer joins
44. If a select list contains both a column as well as a group function then what clause is
required? Mark for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
45. Evaluate this SELECT statement:
![Page 584: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/584.jpg)
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEE table.
The latest hire date in the EMPLOYEE table.
The hire dates in the EMPLOYEE table that contain NULL values
46. Which statement about group functions is true? Mark for Review
(1) Points
![Page 585: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/585.jpg)
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.
47. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
four
two (*)
![Page 586: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/586.jpg)
Group functions cannot be nested.
48. 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
49. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
![Page 587: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/587.jpg)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect Incorrect. Refer to Section 5
50. You need to calculate the standard deviation for the cost of products produced in the
Birmingham facility. Which group function will you use? Mark for Review
![Page 588: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/588.jpg)
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
51. Group functions return a value for ________________ and ________________ null values in
their computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
![Page 589: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/589.jpg)
each row, include
52. You need to calculate the average salary of employees in each department. Which group
function will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
53. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the following?
Mark for Review
(1) Points
Only numeric data types (*)
![Page 590: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/590.jpg)
Integers only
Any data type
All except numeric
54. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
![Page 591: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/591.jpg)
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
55. 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)
![Page 592: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/592.jpg)
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 (*)
56. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark
for Review
(1) Points
![Page 593: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/593.jpg)
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
![Page 594: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/594.jpg)
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_it
58. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
Mark for Review
(1) Points
![Page 595: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/595.jpg)
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
![Page 596: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/596.jpg)
59. 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.
An error occurs because no WHERE clause is included in the SELECT statement.
60. Evaluate this statement:
![Page 597: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/597.jpg)
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)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
![Page 598: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/598.jpg)
61. 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;
![Page 599: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/599.jpg)
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
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 HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
(*)
62. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
![Page 600: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/600.jpg)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
![Page 601: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/601.jpg)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
3. 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)) (*)
![Page 602: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/602.jpg)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
65. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
66. Evaluate this SELECT statement:
![Page 603: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/603.jpg)
SELECT SUM(salary), dept_id
FROM employee
GROUP BY dept_id;
How are the results of this statement sorted?
Mark for Review
(1) Points
Ascending order by dept_id (*)
Descending order by dept_id
Ascending order by cumulative salary
Descending order by cumulative salary
67. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
![Page 604: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/604.jpg)
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
![Page 605: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/605.jpg)
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect Incorrect. Refer to Section 6
Previous Page 67 of 100 Next Summary
68. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
![Page 606: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/606.jpg)
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Incorrect Incorrect. Refer to Section 6
Previous Page 68 of 100 Next Summary
69. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
![Page 607: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/607.jpg)
<>
=
LIKE
70. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
![Page 608: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/608.jpg)
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
71. Using a subquery in which clause will return a syntax error? Mark for Review
(1) Points
WHERE
FROM
HAVING
![Page 609: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/609.jpg)
There are no places you cannot place subqueries. (*)
72. You need to display all the players whose salaries are greater than or equal to John Brown's
salary. Which comparison operator should you use? Mark for Review
(1) Points
=
>
<=
>= (*)
73. Which best describes a single-row subquery? Mark for Review
(1) Points
a query that returns only one row from the inner SELECT statement (*)
![Page 610: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/610.jpg)
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
74. 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)
![Page 611: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/611.jpg)
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
75. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
![Page 612: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/612.jpg)
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row. (*)
76. Which operator or keyword cannot be used with a multiple-row subquery? Mark for
Review
(1) Points
ALL
ANY
= (*)
>
![Page 613: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/613.jpg)
77. Which comparison operator would you use to compare a value to every value returned
by a subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Correct Correct
78. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
 FROM teams
![Page 614: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/614.jpg)
 WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
79. What would happen if you attempted to use a single-row operator with a multiple-row
subquery? Mark for Review
(1) Points
An error would be returned. (*)
![Page 615: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/615.jpg)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Incorrect Incorrect. Refer to Section 6
80. 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
![Page 616: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/616.jpg)
A query that returns one or more
81. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
 FROM manufacturers
 WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
![Page 617: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/617.jpg)
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
 FROM manufacturers
 WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
 FROM manufacturers m
 JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
![Page 618: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/618.jpg)
 FROM manufacturers)
 WHERE cost > AVG(cost);
Correct Correct
Previous Page 81 of 100 Next Summary
82. Which of the following best describes the meaning of the ANY operator? Mark for
Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
![Page 619: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/619.jpg)
Equal to each value in the list
83. 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 SEL
84. Which statement about the ANY operator when used with a multiple-row subquery is
true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
![Page 620: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/620.jpg)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
85. You need to create a SELECT statement that contains a multiple-row subquery, which
comparison operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
![Page 621: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/621.jpg)
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
87. 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
![Page 622: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/622.jpg)
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.
88. The PRODUCTS table contains these columns:
![Page 623: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/623.jpg)
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column
You issue this statement:
INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);
What row data did you add to the table?
Mark for Review
(1) Points
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
![Page 624: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/624.jpg)
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
89. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
![Page 625: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/625.jpg)
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
90. You need to add a row to an existing table. Which DML statement should you use? Mark
for Review
(1) Points
UPDATE
INSERT (*)
![Page 626: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/626.jpg)
DELETE
CREATE
91. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE
table using one UPDATE statement. Which clause should you include in the UPDATE statement to
update multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
92. What keyword in an UPDATE statement speficies the columns you want to change? Mark
for Review
(1) Points
![Page 627: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/627.jpg)
SELECT
WHERE
SET (*)
HAVING
93. One of the sales representatives, Janet Roper, has informed you that she was recently married,
and she has requested that you update her name in the employee database. Her new last name is
Cooper. Janet is the only person with the last name of Roper that is employed by the company. The
EMPLOYEES table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
![Page 628: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/628.jpg)
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
![Page 629: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/629.jpg)
94. Which two commands can be used to modify existing data in a database row? Mark for
Review
(1) Points
(Choose all correct answers)
DELETE
INSERT (*)
SELECT
UPDATE (*)
95. 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)
![Page 630: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/630.jpg)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
Mark for Review
(1) Points
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
DELETE * FROM employees WHERE id_num = 348;
DELETE 'jones' FROM employees;
Incorrect Incorrect. Refer to Section 7
96. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
![Page 631: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/631.jpg)
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?
Mark for Review
(1) Points
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.
![Page 632: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/632.jpg)
You need to create a report to display the teachers who teach more classes than the average
number of classes taught by each teacher. (*)
Incorrect Incorrect. Refer to Section 7
96. 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?
Mark for Review
(1) Points
![Page 633: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/633.jpg)
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. (*)
97. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
![Page 634: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/634.jpg)
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
![Page 635: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/635.jpg)
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
97. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
![Page 636: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/636.jpg)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for
98. What would happen if you issued a DELETE statement without a WHERE clause? Mark
for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
![Page 637: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/637.jpg)
No rows would be deleted.
Only one row would be deleted.
Incorrect Incorrect. Refer to Section 7
99. 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(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee number 89898. Currently, all employees in department 10 have the
same salary value. Which statement should you execute?
Mark for Review
(1) Points
![Page 638: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/638.jpg)
UPDATE employee
SET salary = SELECT salary
FROM employee
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
100. Which of the following represents the correct syntax for an INSERT statement? Mark
for Review
(1) Points
![Page 639: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/639.jpg)
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777');
(*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
![Page 640: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/640.jpg)
LPAD
CUT
NVL2
TRIM (*)
Correct
2. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
![Page 641: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/641.jpg)
Correct
3. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
![Page 642: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/642.jpg)
4. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
TRUNC
SUBSTR (*)
CONCAT
Correct
5. You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
![Page 643: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/643.jpg)
(1) Points
1
2
13 (*)
17
Correct
6. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
![Page 644: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/644.jpg)
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Correct
7. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employee;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEE table.
The email address of each employee in the EMPLOYEE table.
![Page 645: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/645.jpg)
The number of characters for each value in the EMAIL column in the employees table. (*)
The maximum number of characters allowed in the EMAIL column.
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. Which two functions can be used to manipulate number or date column values, but NOT character
column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
![Page 646: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/646.jpg)
CONCAT
Correct
9. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employee;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employee;
SELECT ROUND(hire_date, 'MON')
FROM employee;
SELECT TRUNC(hire_date, 'MI')
FROM employee;
![Page 647: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/647.jpg)
Incorrect. Refer to Section 1 Lesson 3
10. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
![Page 648: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/648.jpg)
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Which SELECT statement will NOT return a date value? Mark for Review
(1) Points
SELECT (30 + hire_date) + 1440/24
FROM employees;
SELECT (SYSDATE - hire_date) + 10*8
FROM employees;
(*)
![Page 649: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/649.jpg)
SELECT SYSDATE - TO_DATE('25-JUN-02') + hire_date
FROM employees;
SELECT (hire_date - SYSDATE) + TO_DATE('25-JUN-02')
FROM employees;
Correct
12. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
![Page 650: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/650.jpg)
Correct
13. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Correct
14. You need to display the current year as a character value (for example: Two Thousand and One).
Which element would you use? Mark for Review
(1) Points
RR
YY
![Page 651: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/651.jpg)
YYYY
YEAR (*)
Correct
15. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
![Page 652: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/652.jpg)
No value is returned because the SELECT statement generates an error.
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
![Page 653: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/653.jpg)
17. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an SQL statement's result
set.
The TO_CHAR function can be used to remove text from column data that will be returned by the
database.
The TO_CHAR function can be used to display dates and numbers according to formatting conventions
that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
Correct
18. You have been asked to create a report that lists all customers who have placed orders of at least
$2,500. The report's date should be displayed in the Day, Date Month, Year format (For example,
Tuesday, 13 April, 2004 ). Which statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
![Page 654: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/654.jpg)
WHERE total >= 2500;
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
Incorrect. Refer to Section 2
19. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
![Page 655: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/655.jpg)
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct
20. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
![Page 656: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/656.jpg)
Correct
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
![Page 657: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/657.jpg)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
![Page 658: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/658.jpg)
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Correct
23. The STYLES table contains this data:
![Page 659: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/659.jpg)
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles
WHERE style_name LIKE 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;
Which result will the query provide?
Mark for Review
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
![Page 660: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/660.jpg)
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
(*)
![Page 661: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/661.jpg)
Correct
24. You need to replace null values in the DEPT_ID column with the text "N/A". Which functions should
you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Correct
Section 3 Lesson 2
(Answer all questions in this section)
![Page 662: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/662.jpg)
25. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
![Page 663: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/663.jpg)
Correct
26. What is produced when a join condition is not specified in a multiple-table query? Mark for
Review
(1) Points
a self-join
an outer join
an equijoin
a Cartesian product (*)
Correct
27. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
![Page 664: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/664.jpg)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
28. Which statement about the join syntax of a SELECT statement is true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Correct
![Page 665: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/665.jpg)
29. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
![Page 666: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/666.jpg)
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
30. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
![Page 667: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/667.jpg)
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
(*)
Correct
Page 3 of 10
![Page 668: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/668.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. 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 =
BETWEEN...AND... and IN
IN and =
Correct
![Page 669: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/669.jpg)
32. 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
33. Which of the following best describes the function of an outer join? Mark for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and the far right column in the
other table.
An outer join will return data only if both tables contain an identical pair of columns.
![Page 670: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/670.jpg)
An outer join will return all rows that meet the join criteria and will return NULL values from one table
if no rows from the other table satisfy the join criteria. (*)
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table.
Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
![Page 671: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/671.jpg)
Correct
35. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Correct
36. A join between tables where the result set includes matching values from both tables but does
NOT return any unmatched rows could be called which of the following? (Choose three) Mark for
Review
(1) Points
(Choose all correct answers)
Equijoin (*)
![Page 672: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/672.jpg)
Self join (*)
Nonequijoin
Simple join (*)
full outer join
Incorrect. Refer to Section 4
Section 4 Lesson 3
(Answer all questions in this section)
37. 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
![Page 673: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/673.jpg)
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)
Correct
38. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
![Page 674: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/674.jpg)
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Correct
39. 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 (*)
Correct
40. For which condition would you use an equijoin query with the USING keyword? Mark for Review
(1) Points
![Page 675: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/675.jpg)
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of columns in
the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column in the PRODUCT
table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID column in the
ORDER table contains null values that need to be displayed.
Correct
Page 4 of 10
Test: Mid Term Exam - Database Programming with SQL
![Page 676: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/676.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. What should be included in a SELECT statement to return NULL values from all tables? Mark for
Review
(1) Points
natural joins
left outer joins
full outer joins (*)
right outer joins
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
![Page 677: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/677.jpg)
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Correct
43. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
![Page 678: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/678.jpg)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Correct
Section 5 Lesson 1
(Answer all questions in this section)
44. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
![Page 679: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/679.jpg)
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
45. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
![Page 680: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/680.jpg)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
46. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
Correct
47. Group functions can be nested to a depth of? Mark for Review
![Page 681: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/681.jpg)
(1) Points
three
four
two (*)
Group functions cannot be nested.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. 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)
![Page 682: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/682.jpg)
SUM
MAX (*)
MIN (*)
AVG
COUNT (*)
Correct
49. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
![Page 683: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/683.jpg)
Correct
50. 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
![Page 684: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/684.jpg)
Correct
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. Which group function would you use to display the average price of all products in the PRODUCTS
table? Mark for Review
(1) Points
SUM
![Page 685: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/685.jpg)
AVG (*)
COUNT
MAX
Correct
52. 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
![Page 686: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/686.jpg)
53. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
![Page 687: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/687.jpg)
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
54. 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)
![Page 688: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/688.jpg)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
Correct
55. Group functions return a value for ________________ and ________________ null values in their
computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
each row, include
![Page 689: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/689.jpg)
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Which statement about the COUNT function is true? Mark for Review
(1) Points
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null values in a column.
Incorrect. Refer to Section 5
57. The EMPLOYEES table contains these columns:
![Page 690: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/690.jpg)
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
![Page 691: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/691.jpg)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Correct
58. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
SELECT
UNLIKE
Correct
![Page 692: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/692.jpg)
59. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Correct
![Page 693: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/693.jpg)
Section 6 Lesson 1
(Answer all questions in this section)
60. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location. You need to include
only the products that have a price less than $25.00. The extended cost of each item equals the quantity
value multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
![Page 694: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/694.jpg)
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
Incorrect. Refer to Section 6
![Page 695: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/695.jpg)
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id
FROM employee
GROUP BY dept_id;
How are the results of this statement sorted?
Mark for Review
(1) Points
![Page 696: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/696.jpg)
Ascending order by dept_id (*)
Descending order by dept_id
Ascending order by cumulative salary
Descending order by cumulative salary
Correct
62. 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)
![Page 697: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/697.jpg)
ORDER BY AVG(salary)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Correct
63. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
![Page 698: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/698.jpg)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Incorrect. Refer to Section 6
64. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
![Page 699: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/699.jpg)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Incorrect. Refer to Section 6
65. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
![Page 700: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/700.jpg)
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section 6
66. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
![Page 701: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/701.jpg)
You must use the HAVING clause with the GROUP BY clause.
Correct
67. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer made a payment
between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
![Page 702: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/702.jpg)
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Incorrect. Refer to Section 6
Section 6 Lesson 2
(Answer all questions in this section)
68. Which statement about subqueries is true? Mark for Review
(1) Points
![Page 703: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/703.jpg)
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Correct
69. Which operator can be used with subqueries that return only one row? Mark for Review
(1) Points
LIKE (*)
ANY
ALL
IN
Correct
![Page 704: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/704.jpg)
70. If you use the equality operator (=) with a subquery, how many values can the subquery return?
Mark for Review
(1) Points
only 1 (*)
up to 2
up to 5
unlimited
Correct
Page 7 of 10
![Page 705: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/705.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. You need to display all the players whose salaries are greater than or equal to John Brown's salary.
Which comparison operator should you use? Mark for Review
(1) Points
=
>
<=
>= (*)
Correct
72. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
![Page 706: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/706.jpg)
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
![Page 707: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/707.jpg)
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. 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
![Page 708: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/708.jpg)
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');
(*)
Correct
![Page 709: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/709.jpg)
74. 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 (*)
![Page 710: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/710.jpg)
the HAVING clause
a MERGE statement
Incorrect. Refer to Section 6
75. 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
![Page 711: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/711.jpg)
Section 6 Lesson 4
(Answer all questions in this section)
76. 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.
![Page 712: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/712.jpg)
Correct
77. Which of the following best describes the meaning of the ANY operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Correct
78. 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);
![Page 713: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/713.jpg)
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. (*)
Correct
79. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
![Page 714: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/714.jpg)
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Correct
80. What is wrong with the following query?
![Page 715: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/715.jpg)
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Correct
Page 8 of 10
![Page 716: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/716.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
FROM teams
WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
![Page 717: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/717.jpg)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
Correct
82. 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. (*)
![Page 718: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/718.jpg)
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
83. 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.
Correct
84. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
![Page 719: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/719.jpg)
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct
85. Which statement about the ANY operator when used with a multiple-row subquery is true? Mark
for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
![Page 720: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/720.jpg)
Correct
86. What would happen if you attempted to use a single-row operator with a multiple-row subquery?
Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. 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
![Page 721: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/721.jpg)
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Correct
88. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
![Page 722: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/722.jpg)
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Correct
89. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
![Page 723: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/723.jpg)
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Correct
![Page 724: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/724.jpg)
90. 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
Page 9 of 10
![Page 725: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/725.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
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
Correct
![Page 726: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/726.jpg)
92. 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? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Correct
93. 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
![Page 727: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/727.jpg)
INSERT, MERGE (*)
INSERT, UPDATE
Correct
94. 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(9,2)
BONUS NUMBER(9,2)
You need to increase the salary for all employees in department 10 by 10 percent. You also need to
increase the bonus for all employees in department 10 by 15 percent. Which statement should you use?
Mark for Review
(1) Points
UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE dept = 10;
(*)
![Page 728: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/728.jpg)
UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE dept = 10;
UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE dept = 10;
UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE dept = 10;
Incorrect. Refer to Section 7
95. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
![Page 729: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/729.jpg)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
![Page 730: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/730.jpg)
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
96. What would happen if you issued a DELETE statement without a WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct
97. Which of the following represents the correct syntax for an INSERT statement? Mark for Review
(1) Points
![Page 731: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/731.jpg)
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Correct
98. 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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
![Page 732: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/732.jpg)
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
99. You need to update the expiration date of products manufactured before June 30th . In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
Correct
![Page 733: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/733.jpg)
100. 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?
Mark for Review
(1) Points
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
DELETE * FROM employees WHERE id_num = 348;
DELETE 'jones' FROM employees;
Correct
![Page 734: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/734.jpg)
Page 10 of 10
1. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
2. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
![Page 735: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/735.jpg)
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Correct
You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
![Page 736: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/736.jpg)
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
4. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 11.00
You query the database and return the value 40. Which script did you use?
Mark for Review
![Page 737: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/737.jpg)
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
(*)
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
Correct
![Page 738: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/738.jpg)
You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
1
2
13 (*)
17
Correct
6. You need to display the number of characters in each customer's last name. Which function should
you use? Mark for Review
(1) Points
![Page 739: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/739.jpg)
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct
7. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
![Page 740: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/740.jpg)
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Correct
. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
![Page 741: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/741.jpg)
Correct
9. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
1 (*)
2
25
0
Correct
10. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
![Page 742: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/742.jpg)
BETWEEN...IN...
IS NULL
Incorrect. Refer to Section 1 Lesson 1
11. Which function would you use to return the current database server date and time? Mark for
Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Correct
12. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
![Page 743: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/743.jpg)
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Correct
13. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
![Page 744: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/744.jpg)
14. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
15. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
![Page 745: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/745.jpg)
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
Incorrect. Refer to Section 1
16. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct
![Page 746: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/746.jpg)
17. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Incorrect. Refer to Section 2
18. 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:
![Page 747: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/747.jpg)
January 28, 2000
Which SELECT statement could you use?
Mark for Review
(1) Points
SELECT TO_CHAR(hire_date, Month DD, YYYY)
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
FROM employees;
(*)
SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
![Page 748: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/748.jpg)
Incorrect. Refer to Section 2
19. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
Incorrect. Refer to Section 2
20. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
![Page 749: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/749.jpg)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
![Page 750: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/750.jpg)
Incorrect. Refer to Section 2
21. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
22. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
![Page 751: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/751.jpg)
NULLIF
COALESCE (*)
Correct
23. When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null? Mark for Review
(1) Points
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
![Page 752: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/752.jpg)
FROM student_accounts;
Incorrect. Refer to Section 2
24. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Correct
25. When joining 3 tables in a SELECT statement, how many join conditions are needed in the WHERE
clause? Mark for Review
(1) Points
0
![Page 753: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/753.jpg)
1
2 (*)
3
Correct
26. You need to create a report that lists all employees in the Sales department who do not earn
$25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
![Page 754: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/754.jpg)
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10;
(*)
Correct
27. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
![Page 755: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/755.jpg)
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
![Page 756: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/756.jpg)
Correct
28. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
![Page 757: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/757.jpg)
Correct
29. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Incorrect. Refer to Section
30. Which statement about the join syntax of a SELECT statement is true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
![Page 758: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/758.jpg)
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Incorrect. Refer to Section 3
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. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
![Page 759: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/759.jpg)
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Correct
33. 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 =
![Page 760: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/760.jpg)
BETWEEN...AND... and IN
IN and =
Incorrect. Refer to Section 3
34. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Incorrect. Refer to Section 4
35. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table.
Which type of join should you create? Mark for Review
(1) Points
An equijoin
![Page 761: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/761.jpg)
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
36. 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
![Page 762: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/762.jpg)
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 (*)
Correct
38. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
![Page 763: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/763.jpg)
Incorrect. Refer to Section 4
39. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in
sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about orders placed by
customers who reside in Nashville . Which query should you issue to achieve the desired results?
Mark for Review
(1) Points
![Page 764: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/764.jpg)
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Correct
![Page 765: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/765.jpg)
40. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
![Page 766: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/766.jpg)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
![Page 767: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/767.jpg)
Incorrect. Refer to Section 4
41. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
![Page 768: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/768.jpg)
JOIN departments d USING (e.department_id = d.department_id);
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Incorrect. Refer to Section 4
43. What should be included in a SELECT statement to return NULL values from all tables? Mark for
Review
(1) Points
natural joins
![Page 769: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/769.jpg)
left outer joins
full outer joins (*)
right outer joins
Incorrect. Refer to Section 4
44. If a select list contains both a column as well as a group function then what clause is required?
Mark for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
Incorrect. Refer to Section 5
45. Evaluate this SELECT statement:
![Page 770: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/770.jpg)
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Incorrect. Refer to Section 5
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.
![Page 771: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/771.jpg)
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.
Incorrect. Refer to Section 5
47. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Incorrect. Refer to Section 5
![Page 772: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/772.jpg)
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
49. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
![Page 773: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/773.jpg)
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
![Page 774: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/774.jpg)
50. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect. Refer to Section 5
51. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
![Page 775: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/775.jpg)
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect. Refer to Section 5
52. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
Mark for Review
(1) Points
AVG
COUNT
MAX
MIN (*)
![Page 776: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/776.jpg)
Incorrect. Refer to Section 5
53. You need to calculate the average salary of employees in each department. Which group function
will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
Correct
54. 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
![Page 777: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/777.jpg)
MAX (*)
MIN (*)
AVG
COUNT (*)
Correct
55. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
![Page 778: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/778.jpg)
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Incorrect. Refer to Section 5
56. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
![Page 779: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/779.jpg)
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
Incorrect. Refer to Section 5
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
![Page 780: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/780.jpg)
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Incorrect. Refer to Section 5
58. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
![Page 781: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/781.jpg)
DISTINCT (*)
SELECT
UNLIKE
Incorrect. Refer to Section 5
59. 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.
An error occurs because no WHERE clause is included in the SELECT statement.
![Page 782: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/782.jpg)
Incorrect. Refer to Section 5
60. 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 (*)
![Page 783: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/783.jpg)
WHERE hire_date > AVG(hire_date)
Incorrect. Refer to Section 6
61. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
![Page 784: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/784.jpg)
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Correct
62. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
![Page 785: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/785.jpg)
HAVING
GROUP BY
WHERE
ORDER BY
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
Correct
![Page 786: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/786.jpg)
63. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
![Page 787: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/787.jpg)
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
64. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
![Page 788: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/788.jpg)
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Correct
65. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
![Page 789: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/789.jpg)
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section
66. 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)
![Page 790: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/790.jpg)
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;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
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 HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
![Page 791: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/791.jpg)
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
(*)
Incorrect. Refer to Section 6
67. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Incorrect. Refer to Section 6
68. Using a subquery in which clause will return a syntax error? Mark for Review
(1) Points
WHERE
![Page 792: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/792.jpg)
FROM
HAVING
There are no places you cannot place subqueries. (*)
Incorrect. Refer to Section 6
69. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
The result of the main query is used with the subquery
Correct
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
![Page 793: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/793.jpg)
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
![Page 794: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/794.jpg)
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
Incorrect. Refer to Section 6
71. The EMPLOYEES and ORDERS tables contain these columns:
![Page 795: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/795.jpg)
EMPLOYEES
EMP_ID NUMBER(10) NOT NULL PRIMARY KEY
FNAME VARCHAR2(30)
LNAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMP_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin
during the year 2001?
Mark for Review
(1) Points
SELECT order_id, total
FROM ORDERS (SELECT emp_id FROM employees WHERE lname = 'Franklin')
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
![Page 796: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/796.jpg)
SELECT (SELECT emp_id FROM employees WHERE lname = 'Franklin') AND order_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT order_id, emp_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE emp_id = (SELECT emp_id FROM employees WHERE lname = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
Correct
72. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
![Page 797: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/797.jpg)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Incorrect. Refer to Section 6
![Page 798: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/798.jpg)
73. 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
![Page 799: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/799.jpg)
WHERE last_name = 'Carter');
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT employee_id
FROM employees
WHERE last_name = 'Carter');
(*)
Incorrect. Refer to Section 6
74. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
![Page 800: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/800.jpg)
an error
Incorrect. Refer to Section 6
75. 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
Incorrect. Refer to Section 6
76. 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 (*)
![Page 801: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/801.jpg)
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
Incorrect. Refer to Section 6
77. 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);
![Page 802: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/802.jpg)
All of the above. (*)
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.
![Page 803: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/803.jpg)
Incorrect. Refer to Section 6
79. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Incorrect. Refer to Section 6
80. Which of the following best describes the meaning of the ANY operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
![Page 804: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/804.jpg)
Compare value to every value returned by the subquery
Equal to each value in the list
Correct
81. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review
(1) Points
ALL
ANY
= (*)
>
Incorrect. Refer
82. What would happen if you attempted to use a single-row operator with a multiple-row subquery?
Mark for Review
(1) Points
An error would be returned. (*)
![Page 805: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/805.jpg)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Incorrect. Refer to Section 6
83. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
![Page 806: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/806.jpg)
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
![Page 807: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/807.jpg)
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
![Page 808: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/808.jpg)
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Incorrect. Refer to Section 6
86. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
![Page 809: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/809.jpg)
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Incorrect. Refer to Section 6
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
![Page 810: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/810.jpg)
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
Incorrect. Refer to Section 7
88. 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
Incorrect. Refer
89. The PRODUCTS table contains these columns:
![Page 811: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/811.jpg)
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Incorrect. Refer to Section 7
90. 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
![Page 812: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/812.jpg)
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Correct
91. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
![Page 813: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/813.jpg)
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Incorrect. Refer to Section 7
![Page 814: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/814.jpg)
92. 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
Correct
93. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
![Page 815: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/815.jpg)
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Correct
![Page 816: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/816.jpg)
94. 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(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee number 89898. Currently, all employees in department 10 have the
same salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employee
SET salary = SELECT salary
FROM employee
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
![Page 817: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/817.jpg)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
Incorrect. Refer to Section 7
95. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
![Page 818: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/818.jpg)
Incorrect. Refer to Section 7
96. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
97. 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?
![Page 819: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/819.jpg)
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
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?
Mark for Review
(1) Points
![Page 820: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/820.jpg)
DELETE FROM employees WHERE id_num = 348; (*)
DELETE FROM employees WHERE lname = jones;
DELETE * FROM employees WHERE id_num = 348;
DELETE 'jones' FROM employees;
Correct
99. You need to update the expiration date of products manufactured before June 30th . In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
Correct
![Page 821: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/821.jpg)
100. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table
using one UPDATE statement. Which clause should you include in the UPDATE statement to update
multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Correct
Section 1 Lesson 1
(Answer all questions in this section)
1. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
![Page 822: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/822.jpg)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Correct
2. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
![Page 823: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/823.jpg)
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
![Page 824: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/824.jpg)
Correct
3. You need to display the number of characters in each customer's last name. Which function should
you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct
4. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
![Page 825: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/825.jpg)
TRUNC
SUBSTR (*)
CONCAT
Correct
5. Which functions can be used to manipulate character, number, and date column values? Mark for
Review
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
Incorrect. Refer to Section 1
![Page 826: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/826.jpg)
6. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
7. You query the database with this SQL statement:
![Page 827: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/827.jpg)
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
LOWER (*)
All three will be evaluated simultaneously.
Correct
Section 1 Lesson 2
(Answer all questions in this section)
![Page 828: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/828.jpg)
8. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
1 (*)
2
25
0
Correct
9. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
![Page 829: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/829.jpg)
Correct
10. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employees;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employees;
SELECT ROUND(hire_date, 'MON')
FROM employees;
SELECT TRUNC(hire_date, 'MI')
FROM employees;
![Page 830: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/830.jpg)
Correct
Page 1 of 10
Section 1 Lesson 3
(Answer all questions in this section)
11. Which SELECT statement will NOT return a date value? Mark for Review
(1) Points
SELECT (30 + hire_date) + 1440/24
FROM employees;
SELECT (SYSDATE - hire_date) + 10*8
FROM employees;
(*)
![Page 831: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/831.jpg)
SELECT SYSDATE - TO_DATE('25-JUN-02') + hire_date
FROM employees;
SELECT (hire_date - SYSDATE) + TO_DATE('25-JUN-02')
FROM employees;
Incorrect. Refer to Section 1
12. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
![Page 832: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/832.jpg)
Correct
13. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
![Page 833: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/833.jpg)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Correct
14. Which function would you use to return the current database server date and time? Mark for
Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Correct
![Page 834: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/834.jpg)
15. The EMPLOYEES 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 employees;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
DATE (*)
NUMBER
DATETIME
![Page 835: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/835.jpg)
INTEGER
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
![Page 836: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/836.jpg)
17. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
18. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an SQL statement's result
set.
The TO_CHAR function can be used to remove text from column data that will be returned by the
database.
![Page 837: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/837.jpg)
The TO_CHAR function can be used to display dates and numbers according to formatting conventions
that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
Incorrect. Refer to Section 2
19. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
Incorrect. Refer to Section 2
20. Which three statements concerning explicit data type conversions are true? (Choose three.) Mark
for Review
![Page 838: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/838.jpg)
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string. (*)
Correct
Page 2 of 10
Section 2 Lesson 1
(Answer all questions in this section)
21. The EMPLOYEES table contains these columns:
![Page 839: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/839.jpg)
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;
SELECT TO_CHAR(hire_date, 'Month DD, YYYY')
FROM employees;
(*)
![Page 840: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/840.jpg)
SELECT hire_date(TO_CHAR 'Month DD', ' YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'Month DD', ' YYYY')
FROM employees;
Incorrect. Refer to Section 2
Section 2 Lesson 2
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
![Page 841: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/841.jpg)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Correct
23. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Incorrect. Refer to Section 2
24. When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null? Mark for Review
(1) Points
![Page 842: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/842.jpg)
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
FROM student_accounts;
Correct
![Page 843: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/843.jpg)
Section 3 Lesson 2
(Answer all questions in this section)
25. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
![Page 844: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/844.jpg)
Incorrect. Refer to Section 3
26. What is the minimum number of join conditions required to join 5 tables together? Mark for
Review
(1) Points
3
4 (*)
5
One more than the number of tables
Incorrect. Refer to Section 3
27. You need to create a report that lists all employees in department 10 (Sales) whose salary is not
equal to $25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND department_id = 10;
![Page 845: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/845.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND department_id = 10;
(*)
Correct
28. Which statement about the join syntax of an Oracle Proprietary join syntax SELECT statement is
true? Mark for Review
(1) Points
![Page 846: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/846.jpg)
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Correct
29. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
![Page 847: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/847.jpg)
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
![Page 848: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/848.jpg)
Correct
30. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated $100,000, or more, in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
(*)
SELECT e.first_name, e.last_name, s.sales
FROM employees, sales
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
SELECT first_name, last_name, sales
Q FROM employees e, sales s
![Page 849: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/849.jpg)
WHERE e.employee_id = s.employee_id AND revenue > 100000;
Correct
Page 3 of 10
Section 3 Lesson 4
(Answer all questions in this section)
31. The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of
the ORDERS table. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you
need to display.
Which type of join should you use to display the data? Mark for Review
(1) Points
natural join
self-join
outer join (*)
equijoin
![Page 850: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/850.jpg)
Correct
32. 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
33. Using Oracle Proprietary join syntax, which two operators can be used in an outer join condition
using the outer join operator (+)? Mark for Review
(1) Points
AND and = (*)
![Page 851: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/851.jpg)
OR and =
BETWEEN...AND... and IN
IN and =
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. The following SQL statement will produce what output?
SELECT last_name, department_name
FROM employees
CROSS JOIN departments;
Mark for Review
(1) Points
The missing rows from the join condition.
![Page 852: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/852.jpg)
The last_name and department name from the employee table.
A Cartesian product between the two tables. (*)
A cross referenced result omitting similar fields from the two tables.
Correct
35. You need to join two tables that have two columns with the same name, datatype and precision.
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
![Page 853: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/853.jpg)
36. You need to join all the rows in the EMPLOYEES table to all the rows in the EMP_REFERENCES
table. Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Correct
Section 4 Lesson 3
(Answer all questions in this section)
37. For which condition would you use an equijoin query with the USING keyword? Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of columns in
the join condition. (*)
![Page 854: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/854.jpg)
The ORDER table contains a column that has a referential constraint to a column in the PRODUCT
table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID column in the
ORDER table contains null values that need to be displayed.
Incorrect. Refer to Section 4
38. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
![Page 855: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/855.jpg)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
![Page 856: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/856.jpg)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Correct
39. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
![Page 857: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/857.jpg)
A join that joins a table to itself
Correct
40. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in
sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about orders placed by
customers who reside in Nashville . Which query should you issue to achieve the desired results?
![Page 858: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/858.jpg)
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
![Page 859: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/859.jpg)
Correct
Page 4 of 10
Section 4 Lesson 4
(Answer all questions in this section)
41. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which
type of join would you use? Mark for Review
(1) Points
a right outer join
a left outer join
a full outer join (*)
an inner join
![Page 860: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/860.jpg)
Correct
42. Which query represents the correct syntax for a left outer join? Mark for Review
(1) Points
SELECT companyname, orderdate, total
FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
(*)
![Page 861: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/861.jpg)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
Correct
43. Which type of join returns rows from one table that have NO direct match in the other table?
Mark for Review
(1) Points
equijoin
self join
outer join (*)
natural join
Correct
![Page 862: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/862.jpg)
Section 5 Lesson 1
(Answer all questions in this section)
44. Evaluate this SELECT statement:
SELECT MIN(hire_date), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEES table.
The latest hire date in the EMPLOYEES table.
The hire dates in the EMPLOYEES table that contain NULL values.
![Page 863: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/863.jpg)
Correct
45. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
four
two (*)
Group functions cannot be nested.
Correct
46. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
![Page 864: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/864.jpg)
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
Correct
47. If a select list contains both columns as well as groups function then what clause is required? Mark
for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
Correct
![Page 865: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/865.jpg)
Section 5 Lesson 2
(Answer all questions in this section)
48. The CUSTOMERS table contains these columns:
CUSTOMER_ID NUMBER(9)
FIRST_NAME VARCHAR2(25)
LAST_NAME 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
![Page 866: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/866.jpg)
Correct
49. 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 (*)
![Page 867: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/867.jpg)
COUNT (*)
Incorrect. Refer to Section 5
50. 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
Page 5 of 10
![Page 868: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/868.jpg)
Section 5 Lesson 2
(Answer all questions in this section)
51. Which aggregate function can be used on a column of the DATE data type? Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Correct
52. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
Mark for Review
(1) Points
![Page 869: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/869.jpg)
AVG
COUNT
MAX
MIN (*)
Correct
53. Which group functions below act on character, number and date data types?
(Choose three) Mark for Review
(1) Points
(Choose all correct answers)
SUM
MAX (*)
MIN (*)
AVG
![Page 870: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/870.jpg)
COUNT (*)
Correct
54. Group functions return a value for ________________ and ________________ null values in their
computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
each row, include
Incorrect. Refer to Section 5
55. Which group function would you use to display the average price of all products in the PRODUCTS
table? Mark for Review
(1) Points
![Page 871: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/871.jpg)
SUM
AVG (*)
COUNT
MAX
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
![Page 872: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/872.jpg)
SELECT
UNLIKE
Correct
57. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
![Page 873: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/873.jpg)
Mark for Review
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
Correct
58. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employees
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.
![Page 874: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/874.jpg)
The total of the SALARY column for all employees that have a salary greater than 30000.
The number of rows in the EMPLOYEES table that have a salary greater than 30000. (*)
The query generates an error and returns no results.
Correct
59. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for
Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Correct
![Page 875: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/875.jpg)
Section 6 Lesson 1
(Answer all questions in this section)
60. 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 three goal keepers.
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)
![Page 876: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/876.jpg)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER' HAVING COUNT(p.player_id) > 3;
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 3;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 3;
(*)
Correct
![Page 877: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/877.jpg)
Page 6 of 10
Section 6 Lesson 1
(Answer all questions in this section)
61. Evaluate this SELECT statement:
SELECT COUNT(emp_id), mgr_id, dept_id
FROM employee
WHERE status = 'I'
GROUP BY dept_id
HAVING salary > 30000
ORDER BY 2;
Why does this statement return a syntax error?
Mark for Review
(1) Points
MGR_ID must be included in the GROUP BY clause. (*)
The HAVING clause must specify an aggregate function.
![Page 878: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/878.jpg)
A single query cannot contain a WHERE clause and a HAVING clause.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
Correct
62. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
![Page 879: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/879.jpg)
Incorrect. Refer to Section 6
63. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
![Page 880: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/880.jpg)
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
64. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
![Page 881: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/881.jpg)
SELECT id_number, name, hire_date, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Correct
65. You want to write a report that returns the average salary of all employees in the company, sorted
by departments. The EMPLOYEES table contains the following columns:
EMPLOYEES:
![Page 882: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/882.jpg)
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
Mark for Review
(1) Points
SELECT salary (AVG)
FROM employees
GROUP BY department;
SELECT AVG (salary)
FROM employees
GROUP BY department;
(*)
SELECT AVG (salary)
FROM employees
BY department;
![Page 883: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/883.jpg)
SELECT AVG salary
FROM employees
BY department;
Correct
66. 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)
![Page 884: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/884.jpg)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct
67. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, department_name
FROM employees
WHERE department_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
![Page 885: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/885.jpg)
WHERE
GROUP BY (*)
Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
![Page 886: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/886.jpg)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Correct
69. If you use the equality operator (=) with a subquery, how many values can the subquery return?
Mark for Review
(1) Points
only 1 (*)
up to 2
![Page 887: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/887.jpg)
up to 5
unlimited
Incorrect. Refer to Section 6
70. Using a subquery in which of the following clauses will return a syntax error? Mark for Review
(1) Points
WHERE
FROM
HAVING
You can use subqueries in all of the above clauses. (*)
Correct
![Page 888: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/888.jpg)
Page 7 of 10
Section 6 Lesson 2
(Answer all questions in this section)
71. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Correct
72. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
![Page 889: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/889.jpg)
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
The result of the main query is used with the subquery
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. Examine the following EMPLOYEES table:
EMPLOYEES
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
SUPERVISOR_ID NUMBER(9)
![Page 890: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/890.jpg)
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
![Page 891: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/891.jpg)
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
74. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
![Page 892: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/892.jpg)
The <> operator can be used when a single-row subquery returns only one row. (*)
Correct
75. 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)
![Page 893: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/893.jpg)
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
Correct
Section 6 Lesson 4
(Answer all questions in this section)
76. 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. (*)
![Page 894: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/894.jpg)
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.
Correct
77. 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. (*)
![Page 895: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/895.jpg)
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.
Incorrect. Refer to Section 6
78. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct
79. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
![Page 896: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/896.jpg)
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE old_dept_id = 15) AND new_dept_id = 10;
(*)
![Page 897: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/897.jpg)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE old_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) =
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE new_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, dept_id
FROM employee
WHERE old_dept_id = 15);
![Page 898: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/898.jpg)
Correct
80. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review
(1) Points
ALL
ANY
= (*)
>
Correct
Page 8 of 10
![Page 899: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/899.jpg)
Section 6 Lesson 4
(Answer all questions in this section)
81. Which comparison operator would you use to compare a value to every value returned by a
subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Correct
82. You are looking for Executive information using a subquery. What will the following SQL statement
display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
![Page 900: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/900.jpg)
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the Executive
department.
The department ID, last name, department name for every Executive in the employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive department. (*)
Correct
83. Which of the following best describes the meaning of the ANY operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
![Page 901: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/901.jpg)
Compare value to every value returned by the subquery
Equal to each value in the list
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
![Page 902: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/902.jpg)
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Correct
85. 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
![Page 903: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/903.jpg)
Correct
86. 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. (*)
![Page 904: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/904.jpg)
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. Which statement about the VALUES clause of an INSERT statement is true? Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the columns are specified in the
table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single quotes in the VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
Incorrect. Refer to Section 7
![Page 905: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/905.jpg)
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
Correct
89. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
![Page 906: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/906.jpg)
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Correct
90. 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
![Page 907: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/907.jpg)
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
Page 9 of 10
Section 7 Lesson 2
(Answer all questions in this section)
91. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
![Page 908: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/908.jpg)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee id 89898. Currently, all employees in department 10 have the same
salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employees
SET salary = SELECT salary
FROM employees
WHERE employee_id = 89898;
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
![Page 909: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/909.jpg)
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id = 10);
Correct
92. What would happen if you issued a DELETE statement without a WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct
93. You need to remove a row from the EMPLOYEES table. Which statement would you use? Mark for
Review
(1) Points
![Page 910: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/910.jpg)
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct
94. 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
![Page 911: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/911.jpg)
Correct
95. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You need to increase the salary for all employees in department 10 by 10 percent. You also need to
increase the bonus for all employees in department 10 by 15 percent. Which statement should you use?
Mark for Review
(1) Points
UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE department_id = 10;
(*)
UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE department_id = 10;
![Page 912: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/912.jpg)
UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE department_id = 10;
UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE department_id = 10;
Correct
96. What keyword in an UPDATE statement specifies the columns you want to change? Mark for
Review
(1) Points
SELECT
WHERE
SET (*)
![Page 913: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/913.jpg)
HAVING
Incorrect. Refer to Section 7
97. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Correct
98. You need to update the expiration date of products manufactured before June 30th. In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
![Page 914: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/914.jpg)
the WHERE clause (*)
the SET clause
the USING clause
Correct
99. Which of the following represents the correct syntax for an INSERT statement? Mark for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES (3178, 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Correct
![Page 915: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/915.jpg)
100. One of the sales representatives, Janet Roper, has informed you that she was recently married,
and she has requested that you update her name in the employee database. Her new last name is
Cooper. Janet is the only person with the last name of Roper that is employed by the company. The
EMPLOYEES table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
![Page 916: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/916.jpg)
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
Correct
Page 10 of 10
Section 1 Lesson 1
(Answer all questions in this section)
![Page 917: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/917.jpg)
1. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
2. Which SQL function is used to return the position where a specific character string begins within a
larger character string? Mark for Review
(1) Points
![Page 918: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/918.jpg)
CONCAT
INSTR (*)
LENGTH
SUBSTR
Correct
3. Which functions can be used to manipulate character, number, and date column values? Mark for
Review
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
![Page 919: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/919.jpg)
Correct
4. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
LOWER (*)
All three will be evaluated simultaneously.
Correct
![Page 920: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/920.jpg)
5. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Correct
6. You need to display the number of characters in each customer's last name. Which function should
you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
![Page 921: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/921.jpg)
COUNT
SUBSTR
Correct
7. The PRICE table contains this data:
PRODUCT_ID MANUFACTURER_ID
86950 59604
You query the database and return the value 95. Which script did you use?
Mark for Review
(1) Points
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
![Page 922: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/922.jpg)
FROM price
WHERE manufacturer_id = 59604;
SELECT SUBSTR(product_id, -1, 3)
FROM price
WHERE manufacturer_id = 59604;
SELECT TRIM(product_id, -3, 2)
FROM price
WHERE manufacturer_id = 59604;
Incorrect. Refer to Section 1
Section 1 Lesson 2
(Answer all questions in this section)
8. Which two functions can be used to manipulate number or date column values, but NOT character
column values? (Choose two.) Mark for Review
(1) Points
![Page 923: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/923.jpg)
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Correct
9. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
![Page 924: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/924.jpg)
700
750 (*)
751
751.3
Correct
10. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employees;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employees;
![Page 925: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/925.jpg)
SELECT ROUND(hire_date, 'MON')
FROM employees;
SELECT TRUNC(hire_date, 'MI')
FROM employees;
Section 1 Lesson 3
(Answer all questions in this section)
11. Which SELECT statement will NOT return a date value? Mark for Review
(1) Points
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;
![Page 926: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/926.jpg)
SELECT (hire_date - SYSDATE) + TO_DATE('25-JUN-02')
FROM employees;
Incorrect. Refer to Section 1
12. Which function would you use to return the current database server date and time? Mark for
Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Correct
![Page 927: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/927.jpg)
13. Which SELECT statement will return a numeric value? Mark for Review
(1) Points
SELECT SYSDATE + 600 / 24
FROM employee;
SELECT ROUND(hire_date, DAY)
FROM employee;
SELECT (SYSDATE - hire_date) / 7
FROM employee;
(*)
SELECT SYSDATE - 7
FROM employee;
Correct
14. Which of the following Date Functions will add calendar months to a date? Mark for Review
![Page 928: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/928.jpg)
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
15. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
![Page 929: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/929.jpg)
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. You have been asked to create a report that lists all customers who have placed orders of at least
$2,500. The report's date should be displayed in the Day, Date Month, Year format (For example,
Tuesday, 13 April, 2004 ). Which statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
![Page 930: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/930.jpg)
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
Correct
17. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
![Page 931: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/931.jpg)
Correct
18. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
19. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
![Page 932: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/932.jpg)
SYSDATE - 6
SYSDATE + 30 / 24
Correct
20. Which three statements concerning explicit data type conversions are true? (Choose three.) Mark
for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string. (*)
Section 2 Lesson 1
![Page 933: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/933.jpg)
(Answer all questions in this section)
21. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
![Page 934: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/934.jpg)
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Correct
23. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
![Page 935: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/935.jpg)
NULLIF
COALESCE (*)
Correct
24. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Correct
![Page 936: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/936.jpg)
Section 3 Lesson 2
(Answer all questions in this section)
25. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
![Page 937: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/937.jpg)
Correct
26. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives
who have generated $100,000, or more, in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
(*)
SELECT e.first_name, e.last_name, s.sales
FROM employees, sales
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
SELECT first_name, last_name, sales
![Page 938: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/938.jpg)
Q FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
Correct
27. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
28. What is produced when a join condition is not specified in a multiple-table query using Oracle
proprietary Join syntax? Mark for Review
(1) Points
![Page 939: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/939.jpg)
a self-join
an outer join
an equijoin
a Cartesian product (*)
Correct
29. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total sales?
![Page 940: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/940.jpg)
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
![Page 941: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/941.jpg)
Correct
30. You have the following EMPLOYEES table:
EMPLOYEE_ID NUMBER(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPARTMENT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:
BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY
ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMPLOYEE_ID VARCHAR2(5) NOT NULL FOREIGN KEY
You want to determine the amount of each employee's bonus, as a calculation of salary times bonus.
Which of the following queries should you issue?
Mark for Review
(1) Points
![Page 942: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/942.jpg)
SELECT e.first_name, e.last_name, b.annual_salary * b. bonus_pct
FROM employees e, bonus b
WHERE e.employee_id = b.employee_id;
(*)
SELECT e.first_name, e.last_name, b.annual_salary, b. bonus_pct
FROM employees e, bonus b
WHERE e.employee_id = b.employee_id;
SELECT e.first_name, e.last_name, b.annual_salary, b. bonus_pct
FROM employees, bonus
WHERE e.employee_id = b.employee_id;
SELECT first_name, last_name, annual_salary * bonus_pct
FROM employees, bonus NATURAL JOIN;
Section 3 Lesson 4
(Answer all questions in this section)
31. Evaluate this SELECT statement:
![Page 943: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/943.jpg)
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Correct
32. Which of the following best describes the function of an outer join? Mark for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
![Page 944: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/944.jpg)
An outer join will return only data from the far left column in one table and the far right column in the
other table.
An outer join will return data only if both tables contain an identical pair of columns.
An outer join will return all rows that meet the join criteria and will return NULL values from one table
if no rows from the other table satisfy the join criteria. (*)
Correct
33. Using Oracle Proprietary join syntax, 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 =
BETWEEN...AND... and IN
IN and =
Correct
![Page 945: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/945.jpg)
Section 4 Lesson 2
(Answer all questions in this section)
34. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Correct
35. Which of the following conditions will cause an error on a NATURAL JOIN? Mark for Review
(1) Points
![Page 946: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/946.jpg)
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
36. You need to join all the rows in the EMPLOYEES table to all the rows in the EMP_REFERENCES
table. Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
![Page 947: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/947.jpg)
Section 4 Lesson 3
(Answer all questions in this section)
37. For which condition would you use an equijoin query with the USING keyword? Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of columns in
the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column in the PRODUCT
table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID column in the
ORDER table contains null values that need to be displayed.
Correct
38. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in
sequence:
![Page 948: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/948.jpg)
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about orders placed by
customers who reside in Nashville . Which query should you issue to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
![Page 949: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/949.jpg)
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Correct
39. Below find the structures of the PRODUCTS and VENDORS tables:
PRODUCTS
![Page 950: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/950.jpg)
PRODUCT_ID NUMBER
PRODUCT_NAME VARCHAR2 (25)
VENDOR_ID NUMBER
CATEGORY_ID NUMBER
VENDORS
VENDOR_ID NUMBER
VENDOR_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
You want to create a query that will return an alphabetical list of products, including the product name
and associated vendor name, for all products that have a vendor assigned.
Which two queries could you use?
Mark for Review
(1) Points
(Choose all correct answers)
SELECT p.product_name, v.vendor_name
FROM products p
LEFT OUTER JOIN vendors v ON p.vendor_id = v.vendor_id
![Page 951: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/951.jpg)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v ON (vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p NATURAL JOIN vendors v
ORDER BY p.product_name;
(*)
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (p.vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (vendor_id)
ORDER BY p.product_name;
![Page 952: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/952.jpg)
(*)
Incorrect. Refer to Section 4
40. 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 don't have matching data types to be joined
Section 4 Lesson 4
(Answer all questions in this section)
41. Which query represents the correct syntax for a left outer join? Mark for Review
(1) Points
SELECT companyname, orderdate, total
![Page 953: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/953.jpg)
FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
![Page 954: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/954.jpg)
Correct
42. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
![Page 955: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/955.jpg)
Incorrect. Refer to Section 4
43. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which
type of join would you use? Mark for Review
(1) Points
a right outer join
a left outer join
a full outer join (*)
an inner join
Correct
Section 5 Lesson 1
(Answer all questions in this section)
![Page 956: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/956.jpg)
44. If a select list contains both columns as well as groups function then what clause is required? Mark
for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
Correct
45. Evaluate this SELECT statement:
SELECT MIN(hire_date), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
![Page 957: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/957.jpg)
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEES table.
The latest hire date in the EMPLOYEES table.
The hire dates in the EMPLOYEES table that contain NULL values.
Correct
46. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
![Page 958: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/958.jpg)
Correct
47. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
Section 5 Lesson 2
![Page 959: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/959.jpg)
(Answer all questions in this section)
48. 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
49. 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
![Page 960: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/960.jpg)
Any data type
All except numeric
Correct
50. 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
Section 5 Lesson 2
(Answer all questions in this section)
51. Which group functions below act on character, number and date data types?
(Choose three) Mark for Review
(1) Points
![Page 961: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/961.jpg)
(Choose all correct answers)
SUM
MAX (*)
MIN (*)
AVG
COUNT (*)
Correct
52. Group functions return a value for ________________ and ________________ null values in their
computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
![Page 962: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/962.jpg)
each row, include
Correct
53. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
Mark for Review
(1) Points
AVG
COUNT
MAX
MIN (*)
Correct
54. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
![Page 963: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/963.jpg)
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
![Page 964: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/964.jpg)
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
55. The CUSTOMERS table contains these columns:
CUSTOMER_ID NUMBER(9)
FIRST_NAME VARCHAR2(25)
LAST_NAME 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
![Page 965: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/965.jpg)
STDDEV
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
![Page 966: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/966.jpg)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
Correct
57. Which statement about the COUNT function is true? Mark for Review
(1) Points
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
![Page 967: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/967.jpg)
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null values in a column.
Correct
58. Group functions can avoid computations involving duplicate values by including which keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
SELECT
UNLIKE
Correct
59. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for
Review
![Page 968: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/968.jpg)
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Correct
Section 6 Lesson 1
(Answer all questions in this section)
60. Evaluate this SELECT statement:
SELECT SUM(salary), department_id
FROM employees
GROUP BY department_id;
How are the results of this statement sorted?
![Page 969: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/969.jpg)
Mark for Review
(1) Points
Ascending order by department_id (*)
Descending order by department_id
Ascending order by cumulative salary
Descending order by cumulative salar
Section 6 Lesson 1
(Answer all questions in this section)
61. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
![Page 970: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/970.jpg)
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
![Page 971: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/971.jpg)
62. You want to write a report that returns the average salary of all employees in the company, sorted
by departments. The EMPLOYEES table contains the following columns:
EMPLOYEES:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
Mark for Review
(1) Points
SELECT salary (AVG)
FROM employees
GROUP BY department;
SELECT AVG (salary)
FROM employees
GROUP BY department;
(*)
![Page 972: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/972.jpg)
SELECT AVG (salary)
FROM employees
BY department;
SELECT AVG salary
FROM employees
BY department;
Incorrect. Refer to Section 6
63. 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
![Page 973: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/973.jpg)
(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)
Incorrect. Refer to Section 6
64. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
![Page 974: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/974.jpg)
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Correct
65. Evaluate this SELECT statement:
SELECT COUNT(employee_id), department_id
FROM employees
GROUP BY department_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
![Page 975: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/975.jpg)
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Correct
66. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer made a payment
between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
![Page 976: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/976.jpg)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Correct
67. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
![Page 977: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/977.jpg)
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct
Section 6 Lesson 2
(Answer all questions in this section)
![Page 978: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/978.jpg)
68. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
![Page 979: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/979.jpg)
Correct
69. Which operator can be used with subqueries that return only one row? Mark for Review
(1) Points
LIKE (*)
ANY
ALL
IN
Correct
70. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
![Page 980: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/980.jpg)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Section 6 Lesson 2
(Answer all questions in this section)
71. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
![Page 981: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/981.jpg)
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
![Page 982: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/982.jpg)
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
Correct
72. Which operator can be used with a multiple-row subquery? Mark for Review
![Page 983: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/983.jpg)
(1) Points
IN (*)
<>
=
LIKE
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. 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
![Page 984: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/984.jpg)
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
74. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Correct
75. Which comparison operator is best used with a single-row subquery? Mark for Review
![Page 985: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/985.jpg)
(1) Points
ANY
ALL
<> (*)
IN
Correct
Section 6 Lesson 4
(Answer all questions in this section)
76. Which of the following best describes the meaning of the ANY operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
![Page 986: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/986.jpg)
Compare value to every value returned by the subquery
Equal to each value in the list
Correct
77. What would happen if you attempted to use a single-row operator with a multiple-row subquery?
Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Correct
![Page 987: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/987.jpg)
78. 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
79. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
![Page 988: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/988.jpg)
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE old_dept_id = 15) AND new_dept_id = 10;
(*)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE old_dept_id = 15);
![Page 989: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/989.jpg)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) =
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE new_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, dept_id
FROM employee
WHERE old_dept_id = 15);
Correct
80. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
![Page 990: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/990.jpg)
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
![Page 991: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/991.jpg)
Section 7 Lesson 2
(Answer all questions in this section)
81. A multiple-row operator expects how many values? Mark for Review
(1) Points
One or more (*)
Only one
Two or more
None
Correct
82. 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);
![Page 992: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/992.jpg)
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. (*)
Correct
83. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
![Page 993: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/993.jpg)
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Correct
84. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
![Page 994: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/994.jpg)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
FROM manufacturers
WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
FROM manufacturers
WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
![Page 995: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/995.jpg)
FROM parts
WHERE manufacturers_id IN
(SELECT id
FROM manufacturers m
JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
FROM manufacturers)
WHERE cost > AVG(cost);
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
![Page 996: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/996.jpg)
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Correct
86. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
![Page 997: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/997.jpg)
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
![Page 998: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/998.jpg)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Correct
88. You need to add a row to an existing table. Which DML statement should you use? Mark for
Review
(1) Points
UPDATE
![Page 999: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/999.jpg)
INSERT (*)
DELETE
CREATE
Correct
89. Which statement about the VALUES clause of an INSERT statement is true? Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the columns are specified in the
table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single quotes in the VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
Correct
![Page 1000: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1000.jpg)
90. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
91. You need to remove a row from the EMPLOYEES table. Which statement would you use? Mark for
Review
(1) Points
![Page 1001: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1001.jpg)
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct
92. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
![Page 1002: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1002.jpg)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
![Page 1003: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1003.jpg)
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id <
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
Correct
93. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(10)
![Page 1004: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1004.jpg)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
![Page 1005: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1005.jpg)
Correct
94. You need to update the expiration date of products manufactured before June 30th. In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
Correct
95. What would happen if you issued a DELETE statement without a WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
![Page 1006: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1006.jpg)
No rows would be deleted.
Only one row would be deleted.
Correct
96. 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? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Correct
97. Which two commands can be used to modify existing data in a database row? Mark for Review
![Page 1007: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1007.jpg)
(1) Points
(Choose all correct answers)
DELETE
MERGE (*)
SELECT
UPDATE (*)
Correct
98. What keyword in an UPDATE statement specifies the columns you want to change? Mark for
Review
(1) Points
SELECT
WHERE
SET (*)
![Page 1008: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1008.jpg)
HAVING
Incorrect. Refer to Section 7
99. You need to update the area code of employees that live in Atlanta . Evaluate this partial UPDATE
statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the desired results?
Mark for Review
(1) Points
UPDATE city = Atlanta;
SET city = 'Atlanta';
WHERE city = 'Atlanta'; (*)
LIKE 'At%';
Correct
![Page 1009: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1009.jpg)
100. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES
table using one UPDATE statement. Which clause should you include in the UPDATE statement to
update multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. Which functions can be used to manipulate character, number, and date column values? Mark for
Review
![Page 1010: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1010.jpg)
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
Correct
2. You need to display each employee's name in all uppercase letters. Which function should you use?
Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
![Page 1011: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1011.jpg)
Correct
3. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the nearest whole
number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined character position
to a specified length. (*)
Incorrect. Refer to Section 1
4. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
![Page 1012: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1012.jpg)
LPAD
CUT
NVL2
TRIM (*)
Correct
5. What will the following SQL statement display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
![Page 1013: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1013.jpg)
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Incorrect. Refer to Section 1
6. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
LOWER (*)
![Page 1014: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1014.jpg)
All three will be evaluated simultaneously.
Correct
7. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employees;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEES table.
The email address of each employee in the EMPLOYEES table.
The number of characters for each value in the EMAIL column in the EMPLOYEES table. (*)
The maximum number of characters allowed in the EMAIL column.
![Page 1015: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1015.jpg)
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
![Page 1016: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1016.jpg)
Correct
9. Which two functions can be used to manipulate number or date column values, but NOT character
column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Correct
10. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review
![Page 1017: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1017.jpg)
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employees;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employees;
SELECT ROUND(hire_date, 'MON')
FROM employees;
SELECT TRUNC(hire_date, 'MI')
FROM employees;
Correct
Page 1 of 10
![Page 1018: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1018.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
![Page 1019: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1019.jpg)
Correct
12. Which of the following SQL statements will correctly display the last name and the number of
weeks employed for all employees in department 90? Mark for Review
(1) Points
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
![Page 1020: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1020.jpg)
FROM employees
WHERE department_id = 90;
Correct
13. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
![Page 1021: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1021.jpg)
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Correct
14. The EMPLOYEES table contains these columns:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
HIRE_DATE DATE
EVAL_MONTHS NUMBER(3)
Evaluate this SELECT statement:
![Page 1022: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1022.jpg)
SELECT hire_date + eval_months
FROM employees;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
DATE (*)
NUMBER
DATETIME
INTEGER
Correct
15. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
![Page 1023: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1023.jpg)
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
![Page 1024: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1024.jpg)
SYSDATE + 30 / 24
Correct
17. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an SQL statement's result
set.
The TO_CHAR function can be used to remove text from column data that will be returned by the
database.
The TO_CHAR function can be used to display dates and numbers according to formatting conventions
that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
Correct
18. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
![Page 1025: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1025.jpg)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
![Page 1026: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1026.jpg)
Correct
19. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
20. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
![Page 1027: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1027.jpg)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
Incorrect. Refer to Section 2
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
![Page 1028: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1028.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_CHAR(price, $99,900.99) FROM product;
Correct
Section 2 Lesson 2
![Page 1029: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1029.jpg)
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Incorrect. Refer to Section 2
23. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
![Page 1030: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1030.jpg)
COALESCE (*)
Incorrect. Refer to Section 2
24. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles
WHERE style_name = 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;
![Page 1031: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1031.jpg)
Which result will the query provide?
Mark for Review
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
![Page 1032: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1032.jpg)
STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
(*)
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. When joining 3 tables in a SELECT statement, how many join conditions are needed in the WHERE
clause? Mark for Review
(1) Points
0
![Page 1033: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1033.jpg)
1
2 (*)
3
Incorrect. Refer to Section 3
26. What is the minimum number of join conditions required to join 5 tables together? Mark for
Review
(1) Points
3
4 (*)
5
One more than the number of tables
Incorrect. Refer to Section 3
![Page 1034: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1034.jpg)
27. You need to create a report that lists all employees in department 10 (Sales) whose salary is not
equal to $25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND department_id = 10;
(*)
![Page 1035: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1035.jpg)
Correct
28. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
![Page 1036: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1036.jpg)
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Correct
29. Which statement about the join syntax of an Oracle Proprietary join syntax SELECT statement is
true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Incorrect. Refer to Section 3
30. What happens when you create a Cartesian product? Mark for Review
![Page 1037: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1037.jpg)
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
![Page 1038: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1038.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Using Oracle Proprietary join syntax, 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
32. Which of the following best describes the function of an outer join? Mark for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
![Page 1039: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1039.jpg)
An outer join will return only data from the far left column in one table and the far right column in the
other table.
An outer join will return data only if both tables contain an identical pair of columns.
An outer join will return all rows that meet the join criteria and will return NULL values from one table
if no rows from the other table satisfy the join criteria. (*)
Correct
33. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
![Page 1040: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1040.jpg)
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Incorrect. Refer to Section 3
Section 4 Lesson 2
(Answer all questions in this section)
34. A join between tables where the result set includes matching values from both tables but does
NOT return any unmatched rows could be called which of the following? (Choose three) Mark for
Review
(1) Points
(Choose all correct answers)
Equijoin (*)
Self join (*)
Nonequijoin
![Page 1041: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1041.jpg)
Simple join (*)
Full outer join
Correct
35. The following SQL statement will produce what output?
SELECT last_name, department_name
FROM employees
CROSS JOIN departments;
Mark for Review
(1) Points
The missing rows from the join condition.
The last_name and department name from the employee table.
A Cartesian product between the two tables. (*)
A cross referenced result omitting similar fields from the two tables.
![Page 1042: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1042.jpg)
Correct
36. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Correct
Section 4 Lesson 3
(Answer all questions in this section)
37. Which keyword in a SELECT statement creates an equijoin by specifying a column name common
to both tables? Mark for Review
![Page 1043: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1043.jpg)
(1) Points
A HAVING clause
The FROM clause
The SELECT clause
A USING clause (*)
Correct
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 don't have matching data types to be joined
![Page 1044: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1044.jpg)
Correct
39. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Correct
40. Evaluate this SELECT statement:
SELECT a.last_name || ', ' || a.first_name as "Patient", b.last_name || ', ' || b.first_name as "Physician",
c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id)
![Page 1045: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1045.jpg)
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)
Correct
Page 4 of 10
![Page 1046: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1046.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Correct
![Page 1047: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1047.jpg)
42. Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the
DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
![Page 1048: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1048.jpg)
Correct
43. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which
type of join would you use? Mark for Review
(1) Points
a right outer join
a left outer join
a full outer join (*)
an inner join
Correct
Section 5 Lesson 1
(Answer all questions in this section)
44. Which statement about the GROUP BY clause is true? Mark for Review
![Page 1049: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1049.jpg)
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
Correct
45. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
![Page 1050: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1050.jpg)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
46. 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.
![Page 1051: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1051.jpg)
Correct
47. Evaluate this SELECT statement:
SELECT MIN(hire_date), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEES table.
The latest hire date in the EMPLOYEES table.
The hire dates in the EMPLOYEES table that contain NULL values.
Correct
![Page 1052: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1052.jpg)
Section 5 Lesson 2
(Answer all questions in this section)
48. 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
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
![Page 1053: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1053.jpg)
SUM (*)
VARIANCE
COUNT
Incorrect. Refer to Section 5
50. 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
![Page 1054: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1054.jpg)
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
![Page 1055: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1055.jpg)
VAR_SAMP
VARIANCE
Correct
52. 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
53. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
![Page 1056: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1056.jpg)
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT MIN(AVG(order_amount)) (*)
Incorrect. Refer to Section 5
![Page 1057: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1057.jpg)
54. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
![Page 1058: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1058.jpg)
Correct
55. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
![Page 1059: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1059.jpg)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
Mark for Review
(1) Points
![Page 1060: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1060.jpg)
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT column is
not null. (*)
Correct
57. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
![Page 1061: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1061.jpg)
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
Correct
58. Which statement about the COUNT function is true? Mark for Review
(1) Points
The COUNT function ignores duplicates by default.
![Page 1062: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1062.jpg)
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null values in a column.
Correct
59. 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.
An error occurs because no WHERE clause is included in the SELECT statement.
![Page 1063: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1063.jpg)
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
60. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location. You need to include
only the products that have a price less than $25.00. The extended cost of each item equals the quantity
value multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points
![Page 1064: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1064.jpg)
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
![Page 1065: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1065.jpg)
Correct
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you should use a
WHERE clause. (*)
![Page 1066: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1066.jpg)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Correct
62. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
![Page 1067: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1067.jpg)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Correct
63. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
![Page 1068: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1068.jpg)
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Correct
64. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employee's 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.
![Page 1069: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1069.jpg)
Which of the following SELECT statements will accomplish this task?
Mark for Review
(1) Points
SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT employee_id, last_name, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT employee_id, last_name, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
![Page 1070: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1070.jpg)
SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Incorrect. Refer to Section 6
65. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
![Page 1071: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1071.jpg)
ORDER BY
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
Correct
66. Evaluate this SELECT statement:
![Page 1072: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1072.jpg)
SELECT COUNT(employee_id), department_id
FROM employees
GROUP BY department_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Incorrect. Refer to Section 6
67. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
![Page 1073: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1073.jpg)
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, hire_date, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect. Refer to Section 6
![Page 1074: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1074.jpg)
Section 6 Lesson 2
(Answer all questions in this section)
68. The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(30)
LAST_NAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin
during the year 2001?
![Page 1075: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1075.jpg)
Mark for Review
(1) Points
SELECT order_id, total
FROM ORDERS (SELECT employee_id FROM employees WHERE last_name = 'Franklin')
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT (SELECT employee_id FROM employees WHERE last_name = 'Franklin') AND order_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT order_id, employee_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
![Page 1076: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1076.jpg)
Incorrect. Refer to Section 6
69. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
![Page 1077: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1077.jpg)
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
![Page 1078: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1078.jpg)
Incorrect. Refer to Section 6
70. Which operator can be used with subqueries that return only one row? Mark for Review
(1) Points
LIKE (*)
ANY
ALL
IN
Incorrect. Refer to Section 6
Page 7 of 10
![Page 1079: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1079.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
The result of the main query is used with the subquery
Correct
![Page 1080: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1080.jpg)
72. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
![Page 1081: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1081.jpg)
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row. (*)
Correct
![Page 1082: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1082.jpg)
74. Examine the following EMPLOYEES table:
EMPLOYEES
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
SUPERVISOR_ID NUMBER(9)
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
![Page 1083: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1083.jpg)
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
![Page 1084: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1084.jpg)
75. 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
Incorrect. Refer to Section 6
Section 6 Lesson 4
(Answer all questions in this section)
76. You are looking for Executive information using a subquery. What will the following SQL statement
display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
![Page 1085: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1085.jpg)
FROM departments
WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the Executive
department.
The department ID, last name, department name for every Executive in the employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive department. (*)
Correct
77. A multiple-row operator expects how many values? Mark for Review
(1) Points
One or more (*)
Only one
Two or more
![Page 1086: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1086.jpg)
None
Correct
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.
![Page 1087: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1087.jpg)
Only the rows with CUSTOMER_ID values equal to null would be selected.
Correct
79. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review
(1) Points
ALL
ANY
= (*)
>
Correct
80. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
![Page 1088: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1088.jpg)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
FROM manufacturers
WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
FROM manufacturers
![Page 1089: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1089.jpg)
WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
FROM manufacturers m
JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
FROM manufacturers)
WHERE cost > AVG(cost);
Correct
Page 8 of 10
![Page 1090: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1090.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
![Page 1091: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1091.jpg)
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
82. Which statement about the ANY operator when used with a multiple-row subquery is true? Mark
for Review
(1) Points
![Page 1092: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1092.jpg)
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
Incorrect. Refer to Section 6
83. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
FROM teams
WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
![Page 1093: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1093.jpg)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
Incorrect. Refer to Section 6
84. 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. (*)
![Page 1094: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1094.jpg)
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
85. 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.
Correct
86. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
![Page 1095: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1095.jpg)
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
![Page 1096: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1096.jpg)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Correct
88. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row data to the PRODUCTS table:
![Page 1097: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1097.jpg)
(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column
You issue this statement:
INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);
What row data did you add to the table?
Mark for Review
(1) Points
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
Correct
![Page 1098: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1098.jpg)
89. Using the INSERT statement, and assuming that a column can accept null values, how can you
implicitly insert a null value in a column? Mark for Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Correct
90. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
![Page 1099: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1099.jpg)
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Correct
![Page 1100: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1100.jpg)
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. You need to update the area code of employees that live in Atlanta . Evaluate this partial UPDATE
statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the desired results?
![Page 1101: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1101.jpg)
Mark for Review
(1) Points
UPDATE city = Atlanta;
SET city = 'Atlanta';
WHERE city = 'Atlanta'; (*)
LIKE 'At%';
Incorrect. Refer to Section 7
92. What would happen if you issued a DELETE statement without a WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
![Page 1102: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1102.jpg)
Correct
93. Which of the following represents the correct syntax for an INSERT statement? Mark for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES (3178, 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Incorrect. Refer to Section 7
94. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
![Page 1103: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1103.jpg)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee id 89898. Currently, all employees in department 10 have the same
salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employees
SET salary = SELECT salary
FROM employees
WHERE employee_id = 89898;
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
![Page 1104: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1104.jpg)
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id = 10);
Incorrect. Refer to Section 7
95. What keyword in an UPDATE statement specifies the columns you want to change? Mark for
Review
(1) Points
SELECT
WHERE
SET (*)
HAVING
Incorrect. Refer to Section 7
96. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES table
using one UPDATE statement. Which clause should you include in the UPDATE statement to update
multiple columns? Mark for Review
![Page 1105: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1105.jpg)
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Correct
97. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
![Page 1106: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1106.jpg)
(1) Points
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
Incorrect. Refer to Section 7
![Page 1107: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1107.jpg)
98. 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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
![Page 1108: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1108.jpg)
99. 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:
EMPLOYEE_ID NUMBER(5) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
Mark for Review
(1) Points
DELETE FROM employees WHERE employee_id = 348; (*)
DELETE FROM employees WHERE last_name = jones;
DELETE * FROM employees WHERE employee_id = 348;
DELETE 'jones' FROM employees;
Incorrect. Refer to Section 7
100. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
![Page 1109: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1109.jpg)
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Incorrect. Refer to Section 7
Page 10 of 10
Test: Mid Term Exam - Database Programming with SQL
![Page 1110: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1110.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. What will the following SQL statement display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Correct
![Page 1111: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1111.jpg)
2. You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
1
2
13 (*)
17
Correct
3. Which functions can be used to manipulate character, number, and date column values? Mark for
Review
![Page 1112: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1112.jpg)
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
Incorrect. Refer to Section 1
4. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
![Page 1113: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1113.jpg)
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
![Page 1114: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1114.jpg)
Correct
5. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
6. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employees;
![Page 1115: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1115.jpg)
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEES table.
The email address of each employee in the EMPLOYEES table.
The number of characters for each value in the EMAIL column in the EMPLOYEES table. (*)
The maximum number of characters allowed in the EMAIL column.
Correct
7. You need to display each employee's name in all uppercase letters. Which function should you use?
Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
![Page 1116: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1116.jpg)
TOUPPER
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Correct
![Page 1117: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1117.jpg)
9. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
1 (*)
2
25
0
Correct
10. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employees;
(*)
![Page 1118: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1118.jpg)
SELECT ROUND(hire_date, 'MONTH')
FROM employees;
SELECT ROUND(hire_date, 'MON')
FROM employees;
SELECT TRUNC(hire_date, 'MI')
FROM employees;
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
![Page 1119: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1119.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. The EMPLOYEES 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 employees;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
![Page 1120: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1120.jpg)
DATE (*)
NUMBER
DATETIME
INTEGER
Correct
12. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
![Page 1121: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1121.jpg)
Correct
13. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
![Page 1122: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1122.jpg)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Correct
14. Which of the following SQL statements will correctly display the last name and the number of
weeks employed for all employees in department 90? Mark for Review
(1) Points
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;
![Page 1123: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1123.jpg)
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
15. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
![Page 1124: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1124.jpg)
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
![Page 1125: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1125.jpg)
Correct
17. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct
18. Which functions allow you to perform explicit data type conversions? Mark for Review
(1) Points
ROUND, TRUNC, ADD_MONTHS
LENGTH, SUBSTR, LPAD, TRIM
![Page 1126: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1126.jpg)
TO_CHAR, TO_DATE, TO_NUMBER (*)
NVL, NVL2, NULLIF
Correct
19. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
![Page 1127: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1127.jpg)
20. You have been asked to create a report that lists all customers who have placed orders of at least
$2,500. The report's date should be displayed in the Day, Date Month, Year format (For example,
Tuesday, 13 April, 2004 ). Which statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
![Page 1128: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1128.jpg)
Correct
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for
Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
![Page 1129: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1129.jpg)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_CHAR(price, $99,900.99) FROM product;
Incorrect. Refer to Section 2
Section 2 Lesson 2
(Answer all questions in this section)
22. When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null? Mark for Review
(1) Points
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
![Page 1130: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1130.jpg)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
FROM student_accounts;
Correct
23. Which of the following General Functions will return the first non-null expression in the expression
list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
![Page 1131: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1131.jpg)
COALESCE (*)
Correct
24. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles
WHERE style_name = 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;
![Page 1132: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1132.jpg)
Which result will the query provide?
Mark for Review
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
![Page 1133: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1133.jpg)
STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
(*)
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
![Page 1134: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1134.jpg)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Correct
![Page 1135: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1135.jpg)
26. 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
27. What is produced when a join condition is not specified in a multiple-table query using Oracle
proprietary Join syntax? Mark for Review
(1) Points
a self-join
an outer join
an equijoin
![Page 1136: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1136.jpg)
a Cartesian product (*)
Correct
28. Which statement about the join syntax of an Oracle Proprietary join syntax SELECT statement is
true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Incorrect. Refer to Section 3
29. You need to create a report that lists all employees in department 10 (Sales) whose salary is not
equal to $25,000 per year. Which query should you issue to accomplish this task? Mark for Review
(1) Points
![Page 1137: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1137.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND department_id = 10;
(*)
Correct
![Page 1138: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1138.jpg)
30. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Incorrect. Refer to Section 3
![Page 1139: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1139.jpg)
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
![Page 1140: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1140.jpg)
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Incorrect. Refer to Section 3
32. The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of
the ORDERS table. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you
need to display.
Which type of join should you use to display the data? Mark for Review
(1) Points
natural join
self-join
outer join (*)
![Page 1141: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1141.jpg)
equijoin
Incorrect. Refer to Section 3
33. Which of the following best describes the function of an outer join? Mark for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and the far right column in the
other table.
An outer join will return data only if both tables contain an identical pair of columns.
An outer join will return all rows that meet the join criteria and will return NULL values from one table
if no rows from the other table satisfy the join criteria. (*)
Incorrect. Refer to Section 3
![Page 1142: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1142.jpg)
Section 4 Lesson 2
(Answer all questions in this section)
34. You need to join all the rows in the EMPLOYEES table to all the rows in the EMP_REFERENCES
table. Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
35. The following SQL statement will produce what output?
SELECT last_name, department_name
FROM employees
CROSS JOIN departments;
Mark for Review
(1) Points
![Page 1143: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1143.jpg)
The missing rows from the join condition.
The last_name and department name from the employee table.
A Cartesian product between the two tables. (*)
A cross referenced result omitting similar fields from the two tables.
Correct
36. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
![Page 1144: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1144.jpg)
Incorrect. Refer to Section 4
Section 4 Lesson 3
(Answer all questions in this section)
37. Which of the following statements is the simplest description of a nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Incorrect. Refer to Section 4
38. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
![Page 1145: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1145.jpg)
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
![Page 1146: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1146.jpg)
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Correct
![Page 1147: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1147.jpg)
39. 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 don't have matching data types to be joined
Correct
40. Below find the structures of the PRODUCTS and VENDORS tables:
PRODUCTS
PRODUCT_ID NUMBER
PRODUCT_NAME VARCHAR2 (25)
VENDOR_ID NUMBER
CATEGORY_ID NUMBER
![Page 1148: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1148.jpg)
VENDORS
VENDOR_ID NUMBER
VENDOR_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
You want to create a query that will return an alphabetical list of products, including the product name
and associated vendor name, for all products that have a vendor assigned.
Which two queries could you use?
Mark for Review
(1) Points
(Choose all correct answers)
SELECT p.product_name, v.vendor_name
FROM products p
LEFT OUTER JOIN vendors v ON p.vendor_id = v.vendor_id
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
![Page 1149: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1149.jpg)
JOIN vendors v ON (vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p NATURAL JOIN vendors v
ORDER BY p.product_name;
(*)
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (p.vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (vendor_id)
ORDER BY p.product_name;
(*)
Incorrect. Refer to Section 4
![Page 1150: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1150.jpg)
Page 4 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which
type of join would you use? Mark for Review
(1) Points
a right outer join
a left outer join
a full outer join (*)
an inner join
![Page 1151: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1151.jpg)
Correct
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Correct
43. You need to join the EMPLOYEE_HISTS and EMPLOYEES tables. The EMPLOYEE_HISTS table will be
the first table in the FROM clause. All the matched and unmatched rows in the EMPLOYEES table need
to be displayed. Which type of join will you use? Mark for Review
(1) Points
a cross join
![Page 1152: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1152.jpg)
an inner join
a left outer join
a right outer join (*)
Correct
Section 5 Lesson 1
(Answer all questions in this section)
44. 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.
![Page 1153: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1153.jpg)
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
45. Evaluate this SELECT statement:
SELECT MIN(hire_date), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEES table.
![Page 1154: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1154.jpg)
The latest hire date in the EMPLOYEES table.
The hire dates in the EMPLOYEES table that contain NULL values.
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.
Incorrect. Refer to Section 5
47. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
![Page 1155: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1155.jpg)
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Incorrect. Refer to Section 5
Section 5 Lesson 2
(Answer all questions in this section)
48. The CUSTOMERS table contains these columns:
CUSTOMER_ID NUMBER(9)
FIRST_NAME VARCHAR2(25)
![Page 1156: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1156.jpg)
LAST_NAME 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
49. Which group function would you use to display the highest salary value in the EMPLOYEE table?
Mark for Review
(1) Points
AVG
![Page 1157: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1157.jpg)
COUNT
MAX (*)
MIN
Correct
50. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
![Page 1158: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1158.jpg)
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Correct
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
![Page 1159: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1159.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. Group functions return a value for ________________ and ________________ null values in their
computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
each row, include
Correct
52. You need to compute the total salary for all employees in department 10. Which group function
will you use? Mark for Review
(1) Points
![Page 1160: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1160.jpg)
MAX
SUM (*)
VARIANCE
COUNT
Correct
53. Which aggregate function can be used on a column of the DATE data type? Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Correct
![Page 1161: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1161.jpg)
54. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model = '4x4';
Correct
![Page 1162: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1162.jpg)
55. You need to calculate the average salary of employees in each department. Which group function
will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for
Review
(1) Points
SELECT COUNT(products);
![Page 1163: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1163.jpg)
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Correct
57. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employees
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 EMPLOYEES table that have a salary greater than 30000. (*)
![Page 1164: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1164.jpg)
The query generates an error and returns no results.
Correct
58. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
![Page 1165: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1165.jpg)
(1) Points
0
6
7 (*)
The statement will NOT execute successfully.
Incorrect. Refer to Section 5
59. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 3 is returned. Which SQL statement did you execute?
Mark for Review
![Page 1166: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1166.jpg)
(1) Points
SELECT COUNT(discount) FROM line_item; (*)
SELECT COUNT(*) FROM line_item;
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
60. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer made a payment
between January 1, 2003 and June 30, 2003 ?
![Page 1167: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1167.jpg)
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
![Page 1168: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1168.jpg)
Correct
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
![Page 1169: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1169.jpg)
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)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct
62. Evaluate this SELECT statement:
SELECT COUNT(employee_id), department_id
![Page 1170: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1170.jpg)
FROM employees
GROUP BY department_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Correct
63. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
![Page 1171: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1171.jpg)
You need to display the number of unique types of manufacturers at each location. Which SELECT
statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
![Page 1172: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1172.jpg)
Incorrect. Refer to Section 6
64. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
SELECT
FROM
WHERE
![Page 1173: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1173.jpg)
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
Correct
65. The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)
![Page 1174: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1174.jpg)
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
66. 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
![Page 1175: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1175.jpg)
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 three goal keepers.
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) = 'GOAL KEEPER'
GROUP BY t.team_name;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER' HAVING COUNT(p.player_id) > 3;
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
![Page 1176: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1176.jpg)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 3;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 3;
(*)
Incorrect. Refer to Section 6
67. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
![Page 1177: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1177.jpg)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. You need to display all the players whose salaries are greater than or equal to John Brown's salary.
Which comparison operator should you use? Mark for Review
(1) Points
=
>
<=
![Page 1178: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1178.jpg)
>= (*)
Correct
69. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Correct
70. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
![Page 1179: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1179.jpg)
<>
=
LIKE
Correct
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
![Page 1180: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1180.jpg)
Section 6 Lesson 2
(Answer all questions in this section)
71. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
![Page 1181: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1181.jpg)
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
Correct
72. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
The result of the main query is used with the subquery
Correct
![Page 1182: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1182.jpg)
Section 6 Lesson 3
(Answer all questions in this section)
73. Which comparison operator is best used with a single-row subquery? Mark for Review
(1) Points
ANY
ALL
<> (*)
IN
Incorrect. Refer to Section 6
74. Examine the following EMPLOYEES table:
EMPLOYEES
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
SUPERVISOR_ID NUMBER(9)
![Page 1183: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1183.jpg)
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 =
![Page 1184: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1184.jpg)
(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
75. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
![Page 1185: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1185.jpg)
a null value
an error
Correct
Section 6 Lesson 4
(Answer all questions in this section)
76. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
![Page 1186: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1186.jpg)
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Correct
77. Which comparison operator would you use to compare a value to every value returned by a
subquery? Mark for Review
(1) Points
SOME
![Page 1187: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1187.jpg)
ANY
ALL (*)
IN
Correct
78. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
![Page 1188: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1188.jpg)
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE old_dept_id = 15) AND new_dept_id = 10;
(*)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE old_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) =
![Page 1189: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1189.jpg)
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE new_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, dept_id
FROM employee
WHERE old_dept_id = 15);
Correct
79. 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
![Page 1190: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1190.jpg)
A query that returns one or more column values from the inner SELECT statement
Correct
80. 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);
![Page 1191: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1191.jpg)
All of the above. (*)
Correct
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. A multiple-row operator expects how many values? Mark for Review
(1) Points
![Page 1192: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1192.jpg)
One or more (*)
Only one
Two or more
None
Correct
82. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
![Page 1193: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1193.jpg)
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Correct
83. Evaluate this SELECT statement:
SELECT customer_id, name
FROM customer
WHERE customer_id IN
(SELECT customer_id
![Page 1194: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1194.jpg)
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.
Correct
84. 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.
![Page 1195: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1195.jpg)
Multiple-row subqueries can be used with both single-row and multiple-row operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct
85. 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
![Page 1196: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1196.jpg)
86. You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. 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
![Page 1197: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1197.jpg)
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
![Page 1198: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1198.jpg)
88. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
Mark for Review
(1) Points
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
![Page 1199: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1199.jpg)
Correct
89. 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
90. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column
![Page 1200: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1200.jpg)
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column
You issue this statement:
INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);
What row data did you add to the table?
Mark for Review
(1) Points
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
Incorrect. Refer to Section 7
![Page 1201: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1201.jpg)
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. 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 (*)
![Page 1202: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1202.jpg)
INSERT, UPDATE
Correct
92. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You need to increase the salary for all employees in department 10 by 10 percent. You also need to
increase the bonus for all employees in department 10 by 15 percent. Which statement should you use?
Mark for Review
(1) Points
UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE department_id = 10;
(*)
![Page 1203: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1203.jpg)
UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE department_id = 10;
UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE department_id = 10;
UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE department_id = 10;
Incorrect. Refer to Section 7
93. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
![Page 1204: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1204.jpg)
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Correct
94. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
![Page 1205: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1205.jpg)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
![Page 1206: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1206.jpg)
DELETE FROM products
WHERE supplier_id <
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
Correct
95. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
![Page 1207: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1207.jpg)
Correct
96. What would happen if you issued a DELETE statement without a WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct
97. You need to update the expiration date of products manufactured before June 30th. In which
clause of the UPDATE statement will you specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
![Page 1208: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1208.jpg)
the SET clause
the USING clause
Correct
98. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
![Page 1209: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1209.jpg)
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Correct
99. You need to remove a row from the EMPLOYEES table. Which statement would you use? Mark for
Review
(1) Points
![Page 1210: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1210.jpg)
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct
100. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee id 89898. Currently, all employees in department 10 have the same
salary value. Which statement should you execute?
Mark for Review
(1) Points
![Page 1211: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1211.jpg)
UPDATE employees
SET salary = SELECT salary
FROM employees
WHERE employee_id = 89898;
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id = 10);
Incorrect. Refer to Section 7
![Page 1212: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1212.jpg)
Page 10 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
![Page 1213: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1213.jpg)
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
LOWER (*)
All three will be evaluated simultaneously.
Correct
2. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
TRUNC
![Page 1214: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1214.jpg)
SUBSTR (*)
CONCAT
Correct
3. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employees;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEES table.
The email address of each employee in the EMPLOYEES table.
The number of characters for each value in the EMAIL column in the EMPLOYEES table. (*)
The maximum number of characters allowed in the EMAIL column.
![Page 1215: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1215.jpg)
Correct
4. What will the following SQL statement display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Incorrect. Refer to Section 1
![Page 1216: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1216.jpg)
5. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
6. The STYLES table contains this data:
![Page 1217: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1217.jpg)
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
![Page 1218: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1218.jpg)
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Correct
7. You need to display each employee's name in all uppercase letters. Which function should you use?
Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
![Page 1219: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1219.jpg)
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Incorrect. Refer to Section 1 Lesson 1
![Page 1220: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1220.jpg)
9. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
10. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
![Page 1221: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1221.jpg)
1 (*)
2
25
0
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
![Page 1222: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1222.jpg)
11. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
12. The EMPLOYEES table contains these columns:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
HIRE_DATE DATE
EVAL_MONTHS NUMBER(3)
Evaluate this SELECT statement:
![Page 1223: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1223.jpg)
SELECT hire_date + eval_months
FROM employees;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
DATE (*)
NUMBER
DATETIME
INTEGER
Incorrect. Refer to Section 1
13. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
![Page 1224: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1224.jpg)
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
14. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
![Page 1225: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1225.jpg)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Incorrect. Refer to Section 1
15. Which of the following SQL statements will correctly display the last name and the number of
weeks employed for all employees in department 90? Mark for Review
(1) Points
SELECT last_name, (SYSDATE-hire_date)/7 AS WEEKS
FROM employees
WHERE department_id = 90;
![Page 1226: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1226.jpg)
(*)
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;
Incorrect. Refer to Section 1
Section 2 Lesson 1
![Page 1227: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1227.jpg)
(Answer all questions in this section)
16. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
17. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
![Page 1228: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1228.jpg)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
Incorrect. Refer to Section 2
18. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Incorrect. Refer to Section 2
![Page 1229: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1229.jpg)
19. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Incorrect. Refer to Section 2
20. You have been asked to create a report that lists all customers who have placed orders of at least
$2,500. The report's date should be displayed in the Day, Date Month, Year format (For example,
Tuesday, 13 April, 2004 ). Which statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
![Page 1230: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1230.jpg)
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
Incorrect. Refer to Section 2
Page 2 of 10
![Page 1231: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1231.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. Which three statements concerning explicit data type conversions are true? (Choose three.) Mark
for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
Use the TO_DATE function to convert a date value to character string or number.
![Page 1232: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1232.jpg)
Use the TO_CHAR function to convert a number or date value to character string. (*)
Incorrect. Refer to Section 2
Section 2 Lesson 2
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
Incorrect. Refer to Section 2
![Page 1233: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1233.jpg)
23. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Correct
24. You need to replace null values in the DEPARTMENT_ID column with the text "N/A". Which
functions should you use? Mark for Review
![Page 1234: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1234.jpg)
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. 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
![Page 1235: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1235.jpg)
2 (*)
3
Incorrect. Refer to Section 3
26. You need to provide a list of the first and last names of all employees who work in the Sales
department who earned a bonus and had sales over $50,000. The company president would like the
sales listed starting with the highest amount first. The EMPLOYEES table and the SALES_DEPT table
contain the following columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(8,2)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MANAGER NUMBER(10)
BONUS NUMBER(10)
![Page 1236: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1236.jpg)
EMPLOYEE_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.employee_id = s.employee_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
WHERE e.employee_id = s.employee_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
![Page 1237: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1237.jpg)
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
Incorrect. Refer to Section 3
27. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
![Page 1238: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1238.jpg)
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Incorrect. Refer to Section 3
28. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
![Page 1239: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1239.jpg)
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Incorrect. Refer to Section 3
29. What is produced when a join condition is not specified in a multiple-table query using Oracle
proprietary Join syntax? Mark for Review
(1) Points
a self-join
an outer join
an equijoin
![Page 1240: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1240.jpg)
a Cartesian product (*)
Incorrect. Refer to Section 3
30. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
Page 3 of 10
![Page 1241: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1241.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Using Oracle Proprietary join syntax, 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 =
BETWEEN...AND... and IN
IN and =
![Page 1242: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1242.jpg)
Correct
32. 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.
Incorrect. Refer to Section 3
33. Using Oracle Proprietary join syntax, 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
(+) (*)
*
![Page 1243: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1243.jpg)
+
=
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. You need to join two tables that have two columns with the same name, datatype and precision.
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
![Page 1244: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1244.jpg)
Correct
35. A join between tables where the result set includes matching values from both tables but does
NOT return any unmatched rows could be called which of the following? (Choose three) Mark for
Review
(1) Points
(Choose all correct answers)
Equijoin (*)
Self join (*)
Nonequijoin
Simple join (*)
Full outer join
Incorrect. Refer to Section 4
36. Which of the following conditions will cause an error on a NATURAL JOIN? Mark for Review
(1) Points
![Page 1245: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1245.jpg)
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 keyword in a SELECT statement creates an equijoin by specifying a column name common
to both tables? Mark for Review
(1) Points
A HAVING clause
The FROM clause
![Page 1246: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1246.jpg)
The SELECT clause
A USING clause (*)
Incorrect. Refer to Section 4
38. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
![Page 1247: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1247.jpg)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
![Page 1248: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1248.jpg)
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Incorrect. Refer to Section 4
39. 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 don't have matching data types to be joined
Incorrect. Refer to Section 4
![Page 1249: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1249.jpg)
40. Evaluate this SELECT statement:
SELECT a.last_name || ', ' || a.first_name as "Patient", b.last_name || ', ' || b.first_name 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
![Page 1250: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1250.jpg)
Page 4 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. Which query represents the correct syntax for a left outer join? Mark for Review
(1) Points
SELECT companyname, orderdate, total
FROM customers c
LEFT JOIN orders o
![Page 1251: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1251.jpg)
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
Incorrect. Refer to Section 4
![Page 1252: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1252.jpg)
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Incorrect. Refer to Section 4
43. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which
type of join would you use? Mark for Review
(1) Points
a right outer join
a left outer join
a full outer join (*)
![Page 1253: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1253.jpg)
an inner join
Incorrect. Refer to Section 4
Section 5 Lesson 1
(Answer all questions in this section)
44. Evaluate this SELECT statement:
SELECT MAX(salary), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
![Page 1254: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1254.jpg)
The employees with the highest salaries.
The employee with the highest salary for each department.
Correct
45. Evaluate this SELECT statement:
SELECT MIN(hire_date), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEES table.
The latest hire date in the EMPLOYEES table.
The hire dates in the EMPLOYEES table that contain NULL values.
![Page 1255: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1255.jpg)
Incorrect. Refer to Section 5
46. If a select list contains both columns as well as groups function then what clause is required? Mark
for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
Incorrect. Refer to Section 5
47. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
![Page 1256: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1256.jpg)
four
two (*)
Group functions cannot be nested.
Incorrect. Refer to Section 5
Section 5 Lesson 2
(Answer all questions in this section)
48. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
![Page 1257: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1257.jpg)
Incorrect. Refer to Section 5
49. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model = '4x4';
![Page 1258: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1258.jpg)
Correct
50. 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
Page 5 of 10
![Page 1259: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1259.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. Which aggregate function can be used on a column of the DATE data type? Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Incorrect. Refer to Section 5
![Page 1260: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1260.jpg)
52. 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
53. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
![Page 1261: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1261.jpg)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Incorrect. Refer to Section 5
54. 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
![Page 1262: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1262.jpg)
Any data type
All except numeric
Correct
55. The CUSTOMERS table contains these columns:
CUSTOMER_ID NUMBER(9)
FIRST_NAME VARCHAR2(25)
LAST_NAME 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
![Page 1263: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1263.jpg)
STDDEV
Incorrect. Refer to Section 5
Section 5 Lesson 3
(Answer all questions in this section)
56. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employees
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.
![Page 1264: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1264.jpg)
The number of rows in the EMPLOYEES table that have a salary greater than 30000. (*)
The query generates an error and returns no results.
Correct
57. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
![Page 1265: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1265.jpg)
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Incorrect. Refer to Section 5
58. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
![Page 1266: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1266.jpg)
Mark for Review
(1) Points
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT column is
not null. (*)
Incorrect. Refer to Section 5
59. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for
Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
![Page 1267: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1267.jpg)
SELECT ROWCOUNT FROM products;
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
60. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
![Page 1268: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1268.jpg)
HAVING salary > 100000
Incorrect. Refer to Section 6
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Which statement about the GROUP BY clause is true? Mark for Review
![Page 1269: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1269.jpg)
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you should use a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Correct
62. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer made a payment
between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
![Page 1270: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1270.jpg)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Incorrect. Refer to Section 6
![Page 1271: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1271.jpg)
63. Evaluate this SELECT statement:
SELECT COUNT(emp_id), mgr_id, dept_id
FROM employee
WHERE status = 'I'
GROUP BY dept_id
HAVING salary > 30000
ORDER BY 2;
Why does this statement return a syntax error?
Mark for Review
(1) Points
MGR_ID must be included in the GROUP BY clause. (*)
The HAVING clause must specify an aggregate function.
A single query cannot contain a WHERE clause and a HAVING clause.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
Incorrect. Refer to Section 6
![Page 1272: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1272.jpg)
64. Evaluate this SELECT statement:
SELECT COUNT(employee_id), department_id
FROM employees
GROUP BY department_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Incorrect. Refer to Section 6
65. The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
![Page 1273: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1273.jpg)
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)
Incorrect. Refer to Section 6
66. The EMPLOYEES table contains these columns:
![Page 1274: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1274.jpg)
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, hire_date, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
![Page 1275: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1275.jpg)
Incorrect. Refer to Section 6
67. 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)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
![Page 1276: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1276.jpg)
HAVING AVG(salary) > 35000 (*)
Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Incorrect. Refer to Section 6
![Page 1277: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1277.jpg)
69. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
=
LIKE
Incorrect. Refer to Section 6
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
![Page 1278: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1278.jpg)
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
![Page 1279: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1279.jpg)
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
Incorrect. Refer to Section 6
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
![Page 1280: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1280.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. Using a subquery in which of the following clauses will return a syntax error? Mark for Review
(1) Points
WHERE
FROM
HAVING
You can use subqueries in all of the above clauses. (*)
Correct
72. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
![Page 1281: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1281.jpg)
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Incorrect. Refer to Section 6
![Page 1282: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1282.jpg)
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Incorrect. Refer to Section 6
74. Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS tables.
EMPLOYEE
EMPLOYEE_ID NUMBER(9)
![Page 1283: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1283.jpg)
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
![Page 1284: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1284.jpg)
a MERGE statement
Incorrect. Refer to Section 6
75. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row. (*)
Incorrect. Refer to Section 6
Section 6 Lesson 4
(Answer all questions in this section)
![Page 1285: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1285.jpg)
76. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
Correct
![Page 1286: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1286.jpg)
77. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
![Page 1287: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1287.jpg)
FROM depart_hist
WHERE old_dept_id = 15) AND new_dept_id = 10;
(*)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE old_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) =
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE new_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, dept_id
![Page 1288: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1288.jpg)
FROM employee
WHERE old_dept_id = 15);
Incorrect. Refer to Section 6
78. 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);
![Page 1289: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1289.jpg)
All of the above. (*)
Incorrect. Refer to Section 6
79. 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.
![Page 1290: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1290.jpg)
Only the rows with CUSTOMER_ID values equal to null would be selected.
Incorrect. Refer to Section 6
80. 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.
Correct
Page 8 of 10
![Page 1291: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1291.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. 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
![Page 1292: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1292.jpg)
Correct
82. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Correct
![Page 1293: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1293.jpg)
83. 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
First subquery not enclosed in parenthesis
Single rather than multiple value operator used. (*)
Second subquery found on the right instead of the left side of the operator.
The greater than operator is not valid.
Incorrect. Refer to Section 6
84. Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
![Page 1294: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1294.jpg)
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.
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
![Page 1295: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1295.jpg)
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Incorrect. Refer to Section 6
86. You are looking for Executive information using a subquery. What will the following SQL statement
display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
Mark for Review
(1) Points
![Page 1296: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1296.jpg)
The department ID, department name and last name for every employee in the Executive
department.
The department ID, last name, department name for every Executive in the employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive department. (*)
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. 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
![Page 1297: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1297.jpg)
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.
Incorrect. Refer to Section 7
88. You need to add a row to an existing table. Which DML statement should you use? Mark for
Review
![Page 1298: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1298.jpg)
(1) Points
UPDATE
INSERT (*)
DELETE
CREATE
Correct
89. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
![Page 1299: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1299.jpg)
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Incorrect. Refer to Section 7
![Page 1300: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1300.jpg)
90. 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
Page 9 of 10
![Page 1301: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1301.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
![Page 1302: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1302.jpg)
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
Correct
92. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
![Page 1303: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1303.jpg)
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
![Page 1304: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1304.jpg)
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Incorrect. Refer to Section 7
93. 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
Incorrect. Refer to Section 7
![Page 1305: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1305.jpg)
94. 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? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Incorrect. Refer to Section 7
95. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
![Page 1306: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1306.jpg)
The statement removes the structure of the CUSTOMER table from the database.
Incorrect. Refer to Section 7
96. Which two commands can be used to modify existing data in a database row? Mark for Review
(1) Points
(Choose all correct answers)
DELETE
MERGE (*)
SELECT
UPDATE (*)
Incorrect. Refer to Section 7
97. Examine the structures of the PRODUCTS and SUPPLIERS tables:
![Page 1307: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1307.jpg)
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
![Page 1308: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1308.jpg)
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id <
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
![Page 1309: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1309.jpg)
Correct
98. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Incorrect. Refer to Section 7
99. 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)
![Page 1310: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1310.jpg)
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?
Mark for Review
(1) Points
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. (*)
Incorrect. Refer to Section 7
100. The PLAYERS table contains these columns:
PLAYER_ID NUMBER NOT NULL
![Page 1311: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1311.jpg)
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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Incorrect. Refer to Section 7
Page 10 of 10
![Page 1312: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1312.jpg)
Midl-mari-lipsesc 10 intrebari- 31-40!!!!
S1L2
1.
You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
1
2
13 (*)
17
2.
Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employee;
What will this SELECT statement display?
![Page 1313: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1313.jpg)
The longest e-mail address in the EMPLOYEE table.
The email address of each employee in the EMPLOYEE table.
The number of characters for each value in the EMAIL column in the employees table. (*)
The maximum number of characters allowed in the EMAIL column.
3.
Which SQL function can be used to remove heading or trailing characters (or both) from a character
string?
LPAD
CUT
NVL2
TRIM (*)
![Page 1314: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1314.jpg)
4.
Which functions can be used to manipulate character, number, and date column values?
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
5.
You need to display the number of characters in each customer's last name. Which function should you
use?
LENGTH (*)
LPAD
COUNT
![Page 1315: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1315.jpg)
SUBSTR
6.
Which SQL function is used to return the position where a specific character string begins within a larger
character string?
CONCAT
INSTR (*)
LENGTH
SUBSTR
7.
You need to return a portion of each employee's last name, beginning with the first character up to the
fifth character. Which character function should you use?
INSTR
TRUNC
![Page 1316: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1316.jpg)
SUBSTR (*)
CONCAT
8.
Evaluate this function: MOD (25, 2) Which value is returned?
1 (*)
2
25
0
9.
Which two functions can be used to manipulate number or date column values, but NOT character
column values? (Choose two.)
(Choose all correct answers)
![Page 1317: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1317.jpg)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
10. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
1200
1282
![Page 1318: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1318.jpg)
1282.25
1300 (*)
S1L3
11.
You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue?
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
![Page 1319: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1319.jpg)
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
12.
You need to display the number of months between today's date and each employee's hiredate. Which
function should you use?
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
13.
Which of the following Date Functions will add calendar months to a date?
![Page 1320: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1320.jpg)
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
14.
Which function would you use to return the current database server date and time?
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
![Page 1321: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1321.jpg)
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
S2 L1
![Page 1322: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1322.jpg)
16.
All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result?
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
17.
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
![Page 1323: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1323.jpg)
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees; (*)
18.
Which statement concerning single row functions is true?
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
![Page 1324: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1324.jpg)
Single row functions return one or more results per row.
19.
Which best describes the TO_CHAR function?
The TO_CHAR function can be used to specify meaningful column names in an SQL statement's result
set.
The TO_CHAR function can be used to remove text from column data that will be returned by the
database.
The TO_CHAR function can be used to display dates and numbers according to formatting conventions
that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
20.
![Page 1325: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1325.jpg)
If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what year
would be the result?
2001
1901
2017 (*)
1917
21.
Which functions allow you to perform explicit data type conversions?
ROUND, TRUNC, ADD_MONTHS
LENGTH, SUBSTR, LPAD, TRIM
TO_CHAR, TO_DATE, TO_NUMBER (*)
![Page 1326: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1326.jpg)
NVL, NVL2, NULLIF
S2L2
22.
When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null?
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts; (*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
FROM student_accounts;
23.
![Page 1327: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1327.jpg)
Which of the following General Functions will return the first non-null expression in the expression list?
NVL
NVL2
NULLIF
COALESCE (*)
24.
The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
![Page 1328: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1328.jpg)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
S3 L2
25.
You need to create a report that lists all employees in the Sales department who do not earn $25,000
per year. Which query should you issue to accomplish this task?
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND dept_id = 10;
![Page 1329: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1329.jpg)
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10; (*)
26.
Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
![Page 1330: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1330.jpg)
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
27.
What happens when you create a Cartesian product?
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
28.
What is produced when a join condition is not specified in a multiple-table query?
![Page 1331: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1331.jpg)
a self-join
an outer join
an equijoin
a Cartesian product (*)
29.
The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
![Page 1332: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1332.jpg)
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
30.
Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives who
have generated at least $100,000 in revenue.
Which query should you issue?
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
![Page 1333: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1333.jpg)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
31-40?????
S 4 L4
41. You need to display all the rows from both the EMPLOYEE and EMPLOYEE_HIST tables. Which type
of join would you use?
o a right outer join
o a left outer join
o a full outer join (*)
o an inner join
42. What should be included in a SELECT statement to return NULL values from all tables?
o natural joins
o left outer joins
o full outer joins (*)
o right outer joins
![Page 1334: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1334.jpg)
43. You need to join the EMPLOYEE_HIST and EMPLOYEE tables. The EMPLOYEE_HIST table will be the
first table in the FROM clause. All the matched and unmatched rows in the EMPLOYEE table need to be
displayed. Which type of join will you use?
o a cross join
o an inner join
o a left outer join
o a right outer join (*)
S 5 L1
44. Which statement about the GROUP BY clause is true?
o The first column listed in the GROUP BY clause is the most major grouping. (*)
o The last column listed in the GROUP BY clause is the most major grouping.
o The GROUP BY clause can contain an aggregate function.
o A GROUP BY clause cannot be used without an ORDER BY clause.
45. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
o The earliest hire date in each department. (*)
![Page 1335: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1335.jpg)
o The the earliest hire date in the EMPLOYEE table.
o The latest hire date in the EMPLOYEE table.
o The hire dates in the EMPLOYEE table that contain NULL values.
46. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
o Displays all the employees and groups them by job.
o Displays each job id and the number of people assigned to that job id. (*)
o Displays only the number of job_ids.
o Displays all the jobs with as many people as there are jobs.
47. Group functions can be nested to a depth of
o three
o four
o two (*)
o Group functions cannot be nested.
S 5 L2
48. Which group function would you use to display the total of all salary values in the EMPLOYEE
table?
o SUM (*)
o AVG
o COUNT
![Page 1336: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1336.jpg)
o MAX
49. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
o AVG
o COUNT
o MAX
o MIN (*)
50. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
o SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003'; (*)
o SELECT AVG(payment_amount)
FROM payment;
o SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
o SELECT AVG(payment_amount)
![Page 1337: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1337.jpg)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
S5 L2
51.
The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model IS '4x4';
52.
![Page 1338: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1338.jpg)
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?
AVG (*)
SUM
COUNT
STDDEV
53.
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
![Page 1339: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1339.jpg)
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.)
(Choose all correct answers)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
54.
Which group function would you use to display the highest salary value in the EMPLOYEE table?
![Page 1340: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1340.jpg)
AVG
COUNT
MAX (*)
MIN
55.
Which group function would you use to display the average price of all products in the PRODUCTS table?
SUM
AVG (*)
COUNT
![Page 1341: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1341.jpg)
MAX
S5L3
56.
Which SELECT statement will calculate the number of rows in the PRODUCTS table?
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
57.
Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
![Page 1342: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1342.jpg)
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
58.
Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
The statement will return the greatest value in the INVENTORY table.
![Page 1343: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1343.jpg)
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not
null. (*)
59.
Which statement about the COUNT function is true?
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null values in a column.
![Page 1344: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1344.jpg)
S6L1
60.
What is the correct order of clauses in a SELECT statement?
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
![Page 1345: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1345.jpg)
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
61.
Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
![Page 1346: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1346.jpg)
SELECT
FROM
WHERE
GROUP BY (*)
62.
Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
![Page 1347: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1347.jpg)
HAVING salary > 100000
63.
Evaluate this SELECT statement:
SELECT COUNT(emp_id), mgr_id, dept_id
FROM employee
WHERE status = 'I'
GROUP BY dept_id
HAVING salary > 30000
ORDER BY 2;
Why does this statement return a syntax error?
MGR_ID must be included in the GROUP BY clause. (*)
The HAVING clause must specify an aggregate function.
A single query cannot contain a WHERE clause and a HAVING clause.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
![Page 1348: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1348.jpg)
64.
The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
![Page 1349: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1349.jpg)
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
65.
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.
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
![Page 1350: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1350.jpg)
HAVING AVG(salary) > 35000 (*)
66.
You want to write a report that returns the average salary of all employees in the company, sorted by
departments. The EMPLOYEES table contains the following columns:
EMPLOYEES:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
SELECT salary (AVG)
FROM employees
GROUP BY dept;
SELECT AVG (salary)
FROM employees
GROUP BY dept; (*)
SELECT AVG (salary)
FROM employees
![Page 1351: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1351.jpg)
BY dept;
SELECT AVG salary
FROM employees
BY dept;
67.
Which statement about the GROUP BY clause is true?
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a WHERE
clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
S6L2
![Page 1352: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1352.jpg)
68.
Using a subquery in which clause will return a syntax error?
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
69.
Which operator can be used with subqueries that return only one row?
LIKE (*)
![Page 1353: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1353.jpg)
ANY
ALL
IN
70.
If you use the equality operator (=) with a subquery, how many values can the subquery return?
only 1 (*)
up to 2
up to 5
unlimited
![Page 1354: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1354.jpg)
71.
Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
![Page 1355: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1355.jpg)
72.
Which operator can be used with a multiple-row subquery?
IN (*)
<>
=
LIKE
S6 L3
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)
![Page 1356: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1356.jpg)
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?
a group function
a single-row subquery (*)
the HAVING clause
a MERGE statement
Incorrect. Refer to Section 6
![Page 1357: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1357.jpg)
74.
Which best describes a single-row subquery?
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
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?
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
![Page 1358: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1358.jpg)
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'); (*)
![Page 1359: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1359.jpg)
S6 L4
76. Which best describes a multiple-row subquery?
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
77. You are looking for Executive information using a subquery. What will the following SQL statement
display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
The department ID, department name and last name for every employee in the Executive department.
![Page 1360: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1360.jpg)
The department ID, last name, department name for every Executive in the employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive department. (*)
78. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more than
$50,000.
![Page 1361: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1361.jpg)
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
79. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
![Page 1362: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1362.jpg)
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
80. Which operator or keyword cannot be used with a multiple-row subquery?
ALL
ANY
= (*)
>
81.
Which of the following best describes the meaning of the ANY operator?
![Page 1363: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1363.jpg)
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Incorrect. Refer to Section 6
82.
Which statement about single-row and multiple-row subqueries is true?
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row subqueries.
![Page 1364: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1364.jpg)
Multiple-row subqueries can be used with both single-row and multiple-row operators.
Multiple-row subqueries can only be used in SELECT statements.
83.
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?
An error would be returned.
No rows would be returned by the outer query. (*)
All the rows in the table would be selected.
![Page 1365: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1365.jpg)
Only the rows with CUSTOMER_ID values equal to null would be selected.
Incorrect. Refer to Section 6
84.
Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
![Page 1366: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1366.jpg)
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Incorrect. Refer to Section 6
85.
You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use?
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
86.
Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
![Page 1367: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1367.jpg)
WHERE area_code IN
(SELECT area_code FROM sales WHERE salesperson_id = 20);
Which statement is true about the given subquery?
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.
S7L1
87.
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
![Page 1368: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1368.jpg)
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?
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.
88.
Using the INSERT statement, and assuming that a column can accept null values, how can you implicitly
insert a null value in a column?
Use the NULL keyword.
![Page 1369: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1369.jpg)
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
89.
The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
![Page 1370: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1370.jpg)
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Incorrect. Refer to Section 7
90.
You need to add a row to an existing table. Which DML statement should you use?
UPDATE
INSERT (*)
DELETE
CREATE
![Page 1371: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1371.jpg)
S7L2
91.
You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table using
one UPDATE statement. Which clause should you include in the UPDATE statement to update multiple
columns?
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
92.
Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
![Page 1372: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1372.jpg)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
![Page 1373: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1373.jpg)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Incorrect. Refer to Section 7
93.
What would happen if you issued a DELETE statement without a WHERE clause?
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
94.
One of the sales representatives, Janet Roper, has informed you that she was recently married, and she
has requested that you update her name in the employee database. Her new last name is Cooper. Janet
is the only person with the last name of Roper that is employed by the company. The EMPLOYEES table
contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
![Page 1374: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1374.jpg)
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
![Page 1375: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1375.jpg)
95.
When the WHERE clause is missing in a DELETE statement, what is the result?
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
96.
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 (salary) SET salary = salary * 1.125;
![Page 1376: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1376.jpg)
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
97.
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?
![Page 1377: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1377.jpg)
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. (*)
98.
Evaluate this statement: DELETE FROM customer; Which statement is true?
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
![Page 1378: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1378.jpg)
99.
You need to update the expiration date of products manufactured before June 30th . In which clause of
the UPDATE statement will you specify this condition?
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
100.
You want to enter a new record into the CUSTOMERS table. Which two commands can be used to create
new rows?
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
![Page 1379: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1379.jpg)
INSERT, UPDATE
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
![Page 1380: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1380.jpg)
FROM employees;
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
LOWER (*)
All three will be evaluated simultaneously.
Correct
2. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
TRUNC
![Page 1381: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1381.jpg)
SUBSTR (*)
CONCAT
Correct
3. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employees;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEES table.
The email address of each employee in the EMPLOYEES table.
The number of characters for each value in the EMAIL column in the EMPLOYEES table. (*)
![Page 1382: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1382.jpg)
The maximum number of characters allowed in the EMAIL column.
Correct
4. What will the following SQL statement display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
![Page 1383: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1383.jpg)
Incorrect. Refer to Section 1
5. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
![Page 1384: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1384.jpg)
6. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
![Page 1385: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1385.jpg)
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Correct
7. You need to display each employee's name in all uppercase letters. Which function should you use?
Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
![Page 1386: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1386.jpg)
TOUPPER
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Incorrect. Refer to Section 1 Lesson 1
![Page 1387: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1387.jpg)
9. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
10. Evaluate this function: MOD (25, 2) Which value is returned? Mark for Review
(1) Points
![Page 1388: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1388.jpg)
1 (*)
2
25
0
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Lesson 3
![Page 1389: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1389.jpg)
(Answer all questions in this section)
11. Which of the following Date Functions will add calendar months to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
12. The EMPLOYEES table contains these columns:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
HIRE_DATE DATE
EVAL_MONTHS NUMBER(3)
![Page 1390: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1390.jpg)
Evaluate this SELECT statement:
SELECT hire_date + eval_months
FROM employees;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
DATE (*)
NUMBER
DATETIME
INTEGER
Incorrect. Refer to Section 1
13. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
![Page 1391: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1391.jpg)
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
14. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
![Page 1392: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1392.jpg)
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Incorrect. Refer to Section 1
15. Which of the following SQL statements will correctly display the last name and the number of
weeks employed for all employees in department 90? Mark for Review
(1) Points
SELECT last_name, (SYSDATE-hire_date)/7 AS WEEKS
FROM employees
![Page 1393: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1393.jpg)
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;
Incorrect. Refer to Section 1
![Page 1394: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1394.jpg)
Section 2 Lesson 1
(Answer all questions in this section)
16. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what
year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
17. Which two statements concerning SQL functions are true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
![Page 1395: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1395.jpg)
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type. (*)
Single-row functions manipulate groups of rows to return one result per group of rows.
Incorrect. Refer to Section 2
18. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result? Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
![Page 1396: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1396.jpg)
Incorrect. Refer to Section 2
19. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Incorrect. Refer to Section 2
20. You have been asked to create a report that lists all customers who have placed orders of at least
$2,500. The report's date should be displayed in the Day, Date Month, Year format (For example,
Tuesday, 13 April, 2004 ). Which statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
![Page 1397: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1397.jpg)
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
Incorrect. Refer to Section 2
Page 2 of 10
![Page 1398: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1398.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. Which three statements concerning explicit data type conversions are true? (Choose three.) Mark
for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number. (*)
![Page 1399: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1399.jpg)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string. (*)
Incorrect. Refer to Section 2
Section 2 Lesson 2
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.
![Page 1400: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1400.jpg)
Incorrect. Refer to Section 2
23. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Correct
![Page 1401: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1401.jpg)
24. You need to replace null values in the DEPARTMENT_ID column with the text "N/A". Which
functions should you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. When joining 3 tables in a SELECT statement, how many join conditions are needed in the WHERE
clause? Mark for Review
(1) Points
0
![Page 1402: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1402.jpg)
1
2 (*)
3
Incorrect. Refer to Section 3
26. You need to provide a list of the first and last names of all employees who work in the Sales
department who earned a bonus and had sales over $50,000. The company president would like the
sales listed starting with the highest amount first. The EMPLOYEES table and the SALES_DEPT table
contain the following columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(8,2)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
![Page 1403: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1403.jpg)
MANAGER NUMBER(10)
BONUS NUMBER(10)
EMPLOYEE_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.employee_id = s.employee_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
WHERE e.employee_id = s.employee_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
![Page 1404: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1404.jpg)
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id, s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
Incorrect. Refer to Section 3
27. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
![Page 1405: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1405.jpg)
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Incorrect. Refer to Section 3
28. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
![Page 1406: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1406.jpg)
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Incorrect. Refer to Section 3
29. What is produced when a join condition is not specified in a multiple-table query using Oracle
proprietary Join syntax? Mark for Review
(1) Points
a self-join
an outer join
![Page 1407: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1407.jpg)
an equijoin
a Cartesian product (*)
Incorrect. Refer to Section 3
30. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
Page 3 of 10
![Page 1408: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1408.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Using Oracle Proprietary join syntax, 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 =
BETWEEN...AND... and IN
IN and =
![Page 1409: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1409.jpg)
Correct
32. 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.
Incorrect. Refer to Section 3
33. Using Oracle Proprietary join syntax, 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
(+) (*)
![Page 1410: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1410.jpg)
*
+
=
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. You need to join two tables that have two columns with the same name, datatype and precision.
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
![Page 1411: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1411.jpg)
Correct
35. A join between tables where the result set includes matching values from both tables but does
NOT return any unmatched rows could be called which of the following? (Choose three) Mark for
Review
(1) Points
(Choose all correct answers)
Equijoin (*)
Self join (*)
Nonequijoin
Simple join (*)
Full outer join
Incorrect. Refer to Section 4
![Page 1412: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1412.jpg)
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 keyword in a SELECT statement creates an equijoin by specifying a column name common
to both tables? Mark for Review
(1) Points
A HAVING clause
![Page 1413: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1413.jpg)
The FROM clause
The SELECT clause
A USING clause (*)
Incorrect. Refer to Section 4
38. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
![Page 1414: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1414.jpg)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you
use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
![Page 1415: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1415.jpg)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Incorrect. Refer to Section 4
39. 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 don't have matching data types to be joined
![Page 1416: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1416.jpg)
Incorrect. Refer to Section 4
40. Evaluate this SELECT statement:
SELECT a.last_name || ', ' || a.first_name as "Patient", b.last_name || ', ' || b.first_name 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)
![Page 1417: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1417.jpg)
Incorrect. Refer to Section 4
Page 4 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. Which query represents the correct syntax for a left outer join? Mark for Review
(1) Points
SELECT companyname, orderdate, total
![Page 1418: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1418.jpg)
FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
![Page 1419: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1419.jpg)
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched rows from the first table
specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Incorrect. Refer to Section 4
43. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which
type of join would you use? Mark for Review
(1) Points
a right outer join
a left outer join
![Page 1420: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1420.jpg)
a full outer join (*)
an inner join
Incorrect. Refer to Section 4
Section 5 Lesson 1
(Answer all questions in this section)
44. Evaluate this SELECT statement:
SELECT MAX(salary), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
![Page 1421: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1421.jpg)
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Correct
45. Evaluate this SELECT statement:
SELECT MIN(hire_date), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEES table.
The latest hire date in the EMPLOYEES table.
![Page 1422: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1422.jpg)
The hire dates in the EMPLOYEES table that contain NULL values.
Incorrect. Refer to Section 5
46. If a select list contains both columns as well as groups function then what clause is required? Mark
for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
Incorrect. Refer to Section 5
47. Group functions can be nested to a depth of? Mark for Review
(1) Points
![Page 1423: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1423.jpg)
three
four
two (*)
Group functions cannot be nested.
Incorrect. Refer to Section 5
Section 5 Lesson 2
(Answer all questions in this section)
48. You need to calculate the standard deviation for the cost of products produced in the Birmingham
facility. Which group function will you use? Mark for Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
![Page 1424: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1424.jpg)
VARIANCE
Incorrect. Refer to Section 5
49. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model = '4x4';
![Page 1425: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1425.jpg)
Correct
50. 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
Page 5 of 10
![Page 1426: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1426.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. Which aggregate function can be used on a column of the DATE data type? Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Incorrect. Refer to Section 5
![Page 1427: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1427.jpg)
52. 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
53. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
![Page 1428: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1428.jpg)
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged together.
An error occurs. (*)
Incorrect. Refer to Section 5
54. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the following? Mark
for Review
(1) Points
Only numeric data types (*)
![Page 1429: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1429.jpg)
Integers only
Any data type
All except numeric
Correct
55. The CUSTOMERS table contains these columns:
CUSTOMER_ID NUMBER(9)
FIRST_NAME VARCHAR2(25)
LAST_NAME 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
![Page 1430: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1430.jpg)
COUNT
STDDEV
Incorrect. Refer to Section 5
Section 5 Lesson 3
(Answer all questions in this section)
56. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employees
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.
![Page 1431: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1431.jpg)
The total of the SALARY column for all employees that have a salary greater than 30000.
The number of rows in the EMPLOYEES table that have a salary greater than 30000. (*)
The query generates an error and returns no results.
Correct
57. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000? Which SELECT
would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
![Page 1432: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1432.jpg)
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Incorrect. Refer to Section 5
58. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
![Page 1433: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1433.jpg)
What will occur when the statement is issued?
Mark for Review
(1) Points
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT column is
not null. (*)
Incorrect. Refer to Section 5
59. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for
Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
![Page 1434: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1434.jpg)
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
60. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
![Page 1435: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1435.jpg)
WHERE salary > 100000
HAVING salary > 100000
Incorrect. Refer to Section 6
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
![Page 1436: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1436.jpg)
61. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you should use a
WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Correct
62. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer made a payment
between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
![Page 1437: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1437.jpg)
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
![Page 1438: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1438.jpg)
Incorrect. Refer to Section 6
63. Evaluate this SELECT statement:
SELECT COUNT(emp_id), mgr_id, dept_id
FROM employee
WHERE status = 'I'
GROUP BY dept_id
HAVING salary > 30000
ORDER BY 2;
Why does this statement return a syntax error?
Mark for Review
(1) Points
MGR_ID must be included in the GROUP BY clause. (*)
The HAVING clause must specify an aggregate function.
A single query cannot contain a WHERE clause and a HAVING clause.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
Incorrect. Refer to Section 6
![Page 1439: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1439.jpg)
64. Evaluate this SELECT statement:
SELECT COUNT(employee_id), department_id
FROM employees
GROUP BY department_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Incorrect. Refer to Section 6
65. The PLAYERS table contains these columns:
![Page 1440: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1440.jpg)
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)
Incorrect. Refer to Section 6
![Page 1441: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1441.jpg)
66. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, hire_date, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
![Page 1442: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1442.jpg)
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect. Refer to Section 6
67. 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)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
![Page 1443: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1443.jpg)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
![Page 1444: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1444.jpg)
Incorrect. Refer to Section 6
69. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
=
LIKE
Incorrect. Refer to Section 6
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
![Page 1445: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1445.jpg)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
(Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
![Page 1446: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1446.jpg)
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
Incorrect. Refer to Section 6
Page 7 of 10
![Page 1447: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1447.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. Using a subquery in which of the following clauses will return a syntax error? Mark for Review
(1) Points
WHERE
FROM
HAVING
You can use subqueries in all of the above clauses. (*)
Correct
![Page 1448: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1448.jpg)
72. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
![Page 1449: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1449.jpg)
Incorrect. Refer to Section 6
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Incorrect. Refer to Section 6
74. Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS tables.
![Page 1450: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1450.jpg)
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 (*)
![Page 1451: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1451.jpg)
the HAVING clause
a MERGE statement
Incorrect. Refer to Section 6
75. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row. (*)
Incorrect. Refer to Section 6
![Page 1452: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1452.jpg)
Section 6 Lesson 4
(Answer all questions in this section)
76. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
![Page 1453: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1453.jpg)
Correct
77. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, last_name, first_name, department_id
FROM employee
![Page 1454: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1454.jpg)
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE old_dept_id = 15) AND new_dept_id = 10;
(*)
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE old_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) =
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE new_dept_id = 15);
SELECT employee_id, last_name, first_name, department_id
FROM employee
![Page 1455: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1455.jpg)
WHERE (employee_id, department_id) IN
(SELECT employee_id, dept_id
FROM employee
WHERE old_dept_id = 15);
Incorrect. Refer to Section 6
78. 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
![Page 1456: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1456.jpg)
WHERE code <> ALL (SELECT type_code FROM d_songs);
All of the above. (*)
Incorrect. Refer to Section 6
79. 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. (*)
![Page 1457: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1457.jpg)
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
80. 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.
Correct
Page 8 of 10
![Page 1458: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1458.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. 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
![Page 1459: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1459.jpg)
Correct
82. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
![Page 1460: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1460.jpg)
Correct
83. 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
First subquery not enclosed in parenthesis
Single rather than multiple value operator used. (*)
Second subquery found on the right instead of the left side of the operator.
The greater than operator is not valid.
Incorrect. Refer to Section 6
84. Evaluate this SELECT statement that includes a subquery:
![Page 1461: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1461.jpg)
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.
Incorrect. Refer to Section 6
85. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
![Page 1462: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1462.jpg)
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Incorrect. Refer to Section 6
86. You are looking for Executive information using a subquery. What will the following SQL statement
display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
Mark for Review
![Page 1463: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1463.jpg)
(1) Points
The department ID, department name and last name for every employee in the Executive
department.
The department ID, last name, department name for every Executive in the employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive department. (*)
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. 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
![Page 1464: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1464.jpg)
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.
Incorrect. Refer to Section 7
![Page 1465: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1465.jpg)
88. 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
89. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
![Page 1466: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1466.jpg)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
![Page 1467: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1467.jpg)
Incorrect. Refer to Section 7
90. 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
Page 9 of 10
![Page 1468: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1468.jpg)
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper.
Janet is the only person with the last name of Roper that is employed by the company. The EMPLOYEES
table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID NUMBER(10)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
![Page 1469: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1469.jpg)
(1) Points
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
Correct
![Page 1470: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1470.jpg)
92. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
![Page 1471: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1471.jpg)
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Incorrect. Refer to Section 7
93. 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
![Page 1472: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1472.jpg)
Incorrect. Refer to Section 7
94. 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? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Incorrect. Refer to Section 7
95. Evaluate this statement: DELETE FROM customer; Which statement is true? Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
![Page 1473: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1473.jpg)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Incorrect. Refer to Section 7
96. Which two commands can be used to modify existing data in a database row? Mark for Review
(1) Points
(Choose all correct answers)
DELETE
MERGE (*)
SELECT
UPDATE (*)
Incorrect. Refer to Section 7
![Page 1474: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1474.jpg)
97. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
![Page 1475: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1475.jpg)
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id <
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
![Page 1476: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1476.jpg)
Correct
98. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Incorrect. Refer to Section 7
99. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5)
NAME VARCHAR2(25)
![Page 1477: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1477.jpg)
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?
Mark for Review
(1) Points
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. (*)
Incorrect. Refer to Section 7
![Page 1478: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1478.jpg)
100. 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?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Incorrect. Refer to Section 7
![Page 1479: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1479.jpg)
Page 10 of 10
Midl-mari-lipsesc 10 intrebari- 31-40!!!!
S1L2
1.
You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
1
2
13 (*)
17
2.
Evaluate this SELECT statement:
SELECT LENGTH(email)
![Page 1480: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1480.jpg)
FROM employee;
What will this SELECT statement display?
The longest e-mail address in the EMPLOYEE table.
The email address of each employee in the EMPLOYEE table.
The number of characters for each value in the EMAIL column in the employees table. (*)
The maximum number of characters allowed in the EMAIL column.
3.
Which SQL function can be used to remove heading or trailing characters (or both) from a character
string?
LPAD
CUT
NVL2
![Page 1481: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1481.jpg)
TRIM (*)
4.
Which functions can be used to manipulate character, number, and date column values?
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
5.
You need to display the number of characters in each customer's last name. Which function should you
use?
LENGTH (*)
LPAD
![Page 1482: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1482.jpg)
COUNT
SUBSTR
6.
Which SQL function is used to return the position where a specific character string begins within a larger
character string?
CONCAT
INSTR (*)
LENGTH
SUBSTR
7.
You need to return a portion of each employee's last name, beginning with the first character up to the
fifth character. Which character function should you use?
INSTR
![Page 1483: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1483.jpg)
TRUNC
SUBSTR (*)
CONCAT
8.
Evaluate this function: MOD (25, 2) Which value is returned?
1 (*)
2
25
0
9.
![Page 1484: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1484.jpg)
Which two functions can be used to manipulate number or date column values, but NOT character
column values? (Choose two.)
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
10. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
1200
![Page 1485: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1485.jpg)
1282
1282.25
1300 (*)
S1L3
11.
You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue?
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
![Page 1486: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1486.jpg)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
12.
You need to display the number of months between today's date and each employee's hiredate. Which
function should you use?
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
![Page 1487: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1487.jpg)
13.
Which of the following Date Functions will add calendar months to a date?
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
14.
Which function would you use to return the current database server date and time?
DATE
SYSDATE (*)
DATETIME
![Page 1488: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1488.jpg)
CURRENTDATE
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
![Page 1489: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1489.jpg)
S2 L1
16.
All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a
report that displays each employee's name and salary. Each employee's salary must be displayed in the
following format: $000,000.00. Which function should you include in a SELECT statement to achieve the
desired result?
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
17.
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
![Page 1490: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1490.jpg)
You need to create a report to display the salaries of all employees. Which script should you use to
display the salaries in format: "$45,000.00"?
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees; (*)
18.
Which statement concerning single row functions is true?
Single row functions can accept only one argument, but can return multiple values.
Single row functions cannot modify a data type.
![Page 1491: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1491.jpg)
Single row functions can be nested. (*)
Single row functions return one or more results per row.
19.
Which best describes the TO_CHAR function?
The TO_CHAR function can be used to specify meaningful column names in an SQL statement's result
set.
The TO_CHAR function can be used to remove text from column data that will be returned by the
database.
The TO_CHAR function can be used to display dates and numbers according to formatting conventions
that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
![Page 1492: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1492.jpg)
20.
If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what year
would be the result?
2001
1901
2017 (*)
1917
21.
Which functions allow you to perform explicit data type conversions?
ROUND, TRUNC, ADD_MONTHS
LENGTH, SUBSTR, LPAD, TRIM
TO_CHAR, TO_DATE, TO_NUMBER (*)
![Page 1493: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1493.jpg)
NVL, NVL2, NULLIF
S2L2
22.
When executed, which statement displays a zero if the TUITION_BALANCE value is zero and the
HOUSING_BALANCE value is null?
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts; (*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance + housing_balance "Balance
Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0), tutition_balance +
housing_balance "Balance Due"
FROM student_accounts;
![Page 1494: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1494.jpg)
23.
Which of the following General Functions will return the first non-null expression in the expression list?
NVL
NVL2
NULLIF
COALESCE (*)
24.
The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
![Page 1495: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1495.jpg)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
S3 L2
25.
You need to create a report that lists all employees in the Sales department who do not earn $25,000
per year. Which query should you issue to accomplish this task?
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
![Page 1496: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1496.jpg)
WHERE salary = 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND dept_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND dept_id = 10; (*)
26.
Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
![Page 1497: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1497.jpg)
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
27.
What happens when you create a Cartesian product?
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
28.
What is produced when a join condition is not specified in a multiple-table query?
![Page 1498: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1498.jpg)
a self-join
an outer join
an equijoin
a Cartesian product (*)
29.
The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
![Page 1499: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1499.jpg)
Which result will this statement provide?
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
30.
Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives who
have generated at least $100,000 in revenue.
Which query should you issue?
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
![Page 1500: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1500.jpg)
(*)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
31-40?????
S 4 L4
41. You need to display all the rows from both the EMPLOYEE and EMPLOYEE_HIST tables. Which type
of join would you use?
o a right outer join
o a left outer join
o a full outer join (*)
o an inner join
42. What should be included in a SELECT statement to return NULL values from all tables?
o natural joins
o left outer joins
o full outer joins (*)
![Page 1501: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1501.jpg)
o right outer joins
43. You need to join the EMPLOYEE_HIST and EMPLOYEE tables. The EMPLOYEE_HIST table will be the
first table in the FROM clause. All the matched and unmatched rows in the EMPLOYEE table need to be
displayed. Which type of join will you use?
o a cross join
o an inner join
o a left outer join
o a right outer join (*)
S 5 L1
44. Which statement about the GROUP BY clause is true?
o The first column listed in the GROUP BY clause is the most major grouping. (*)
o The last column listed in the GROUP BY clause is the most major grouping.
o The GROUP BY clause can contain an aggregate function.
o A GROUP BY clause cannot be used without an ORDER BY clause.
45. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
![Page 1502: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1502.jpg)
o The earliest hire date in each department. (*)
o The the earliest hire date in the EMPLOYEE table.
o The latest hire date in the EMPLOYEE table.
o The hire dates in the EMPLOYEE table that contain NULL values.
46. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
o Displays all the employees and groups them by job.
o Displays each job id and the number of people assigned to that job id. (*)
o Displays only the number of job_ids.
o Displays all the jobs with as many people as there are jobs.
47. Group functions can be nested to a depth of
o three
o four
o two (*)
o Group functions cannot be nested.
S 5 L2
48. Which group function would you use to display the total of all salary values in the EMPLOYEE
table?
o SUM (*)
o AVG
![Page 1503: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1503.jpg)
o COUNT
o MAX
49. Which group function would you use to display the lowest value in the SALES_AMOUNT column?
o AVG
o COUNT
o MAX
o MIN (*)
50. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February and
March of 2003. Which SELECT statement should you use?
o SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003'; (*)
o SELECT AVG(payment_amount)
FROM payment;
o SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
![Page 1504: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1504.jpg)
o SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
S5 L2
51.
The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model IS '4x4';
![Page 1505: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1505.jpg)
52.
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?
AVG (*)
SUM
COUNT
STDDEV
53.
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
![Page 1506: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1506.jpg)
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.)
(Choose all correct answers)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
54.
Which group function would you use to display the highest salary value in the EMPLOYEE table?
![Page 1507: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1507.jpg)
AVG
COUNT
MAX (*)
MIN
55.
Which group function would you use to display the average price of all products in the PRODUCTS table?
SUM
AVG (*)
COUNT
![Page 1508: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1508.jpg)
MAX
S5L3
56.
Which SELECT statement will calculate the number of rows in the PRODUCTS table?
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
57.
Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
![Page 1509: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1509.jpg)
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did you execute?
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
58.
Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
The statement will return the greatest value in the INVENTORY table.
![Page 1510: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1510.jpg)
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not
null. (*)
59.
Which statement about the COUNT function is true?
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null values in a column.
![Page 1511: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1511.jpg)
S6L1
60.
What is the correct order of clauses in a SELECT statement?
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
![Page 1512: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1512.jpg)
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
61.
Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
![Page 1513: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1513.jpg)
SELECT
FROM
WHERE
GROUP BY (*)
62.
Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a group function?
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
![Page 1514: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1514.jpg)
WHERE salary > 100000
HAVING salary > 100000
63.
Evaluate this SELECT statement:
SELECT COUNT(emp_id), mgr_id, dept_id
FROM employee
WHERE status = 'I'
GROUP BY dept_id
HAVING salary > 30000
ORDER BY 2;
Why does this statement return a syntax error?
MGR_ID must be included in the GROUP BY clause. (*)
The HAVING clause must specify an aggregate function.
A single query cannot contain a WHERE clause and a HAVING clause.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
![Page 1515: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1515.jpg)
64.
The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
![Page 1516: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1516.jpg)
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
65.
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.
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
![Page 1517: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1517.jpg)
HAVING AVG(salary) > 35000 (*)
66.
You want to write a report that returns the average salary of all employees in the company, sorted by
departments. The EMPLOYEES table contains the following columns:
EMPLOYEES:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
SELECT salary (AVG)
FROM employees
GROUP BY dept;
SELECT AVG (salary)
FROM employees
GROUP BY dept; (*)
SELECT AVG (salary)
![Page 1518: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1518.jpg)
FROM employees
BY dept;
SELECT AVG salary
FROM employees
BY dept;
67.
Which statement about the GROUP BY clause is true?
To exclude rows before dividing them into groups using the GROUP BY clause, you use should a WHERE
clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
S6L2
![Page 1519: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1519.jpg)
68.
Using a subquery in which clause will return a syntax error?
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
69.
Which operator can be used with subqueries that return only one row?
LIKE (*)
![Page 1520: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1520.jpg)
ANY
ALL
IN
70.
If you use the equality operator (=) with a subquery, how many values can the subquery return?
only 1 (*)
up to 2
up to 5
unlimited
![Page 1521: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1521.jpg)
71.
Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired results?
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order number 25950. (*)
![Page 1522: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1522.jpg)
72.
Which operator can be used with a multiple-row subquery?
IN (*)
<>
=
LIKE
S6 L3
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
![Page 1523: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1523.jpg)
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?
a group function
a single-row subquery (*)
the HAVING clause
a MERGE statement
![Page 1524: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1524.jpg)
Incorrect. Refer to Section 6
74.
Which best describes a single-row subquery?
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
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?
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
![Page 1525: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1525.jpg)
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'); (*)
![Page 1526: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1526.jpg)
S6 L4
76. Which best describes a multiple-row subquery?
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
77. You are looking for Executive information using a subquery. What will the following SQL statement
display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
The department ID, department name and last name for every employee in the Executive department.
![Page 1527: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1527.jpg)
The department ID, last name, department name for every Executive in the employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive department. (*)
78. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
![Page 1528: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1528.jpg)
All employees who work in a department with employees who earn more than $30,000 and more than
$50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
79. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
![Page 1529: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1529.jpg)
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
80. Which operator or keyword cannot be used with a multiple-row subquery?
ALL
ANY
= (*)
>
81.
![Page 1530: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1530.jpg)
Which of the following best describes the meaning of the ANY operator?
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Incorrect. Refer to Section 6
82.
Which statement about single-row and multiple-row subqueries is true?
Multiple-row subqueries cannot be used with the LIKE operator. (*)
![Page 1531: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1531.jpg)
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.
83.
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?
An error would be returned.
No rows would be returned by the outer query. (*)
All the rows in the table would be selected.
![Page 1532: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1532.jpg)
Only the rows with CUSTOMER_ID values equal to null would be selected.
Incorrect. Refer to Section 6
84.
Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
![Page 1533: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1533.jpg)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Incorrect. Refer to Section 6
85.
You need to create a SELECT statement that contains a multiple-row subquery, which comparison
operator(s) can you use?
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
86.
Evaluate this SELECT statement that includes a subquery:
![Page 1534: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1534.jpg)
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?
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.
S7L1
87.
The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
![Page 1535: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1535.jpg)
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?
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.
88.
Using the INSERT statement, and assuming that a column can accept null values, how can you implicitly
insert a null value in a column?
![Page 1536: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1536.jpg)
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
89.
The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700); (*)
![Page 1537: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1537.jpg)
INSERT INTO products VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name) VALUES (2958, 'Cable');
INSERT INTO products(product_id, product_name, supplier_id VALUES (2958, 'Cable', 8690, SYSDATE);
Incorrect. Refer to Section 7
90.
You need to add a row to an existing table. Which DML statement should you use?
UPDATE
INSERT (*)
DELETE
![Page 1538: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1538.jpg)
CREATE
S7L2
91.
You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table using
one UPDATE statement. Which clause should you include in the UPDATE statement to update multiple
columns?
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
92.
Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
![Page 1539: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1539.jpg)
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
![Page 1540: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1540.jpg)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Incorrect. Refer to Section 7
93.
What would happen if you issued a DELETE statement without a WHERE clause?
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
94.
One of the sales representatives, Janet Roper, has informed you that she was recently married, and she
has requested that you update her name in the employee database. Her new last name is Cooper. Janet
![Page 1541: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1541.jpg)
is the only person with the last name of Roper that is employed by the company. The EMPLOYEES table
contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
![Page 1542: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1542.jpg)
SET cooper = 'lname'
WHERE lname = 'roper';
95.
When the WHERE clause is missing in a DELETE statement, what is the result?
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
96.
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?
![Page 1543: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1543.jpg)
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
97.
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)
![Page 1544: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1544.jpg)
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. (*)
98.
Evaluate this statement: DELETE FROM customer; Which statement is true?
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
![Page 1545: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1545.jpg)
The statement removes the structure of the CUSTOMER table from the database.
99.
You need to update the expiration date of products manufactured before June 30th . In which clause of
the UPDATE statement will you specify this condition?
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
100.
You want to enter a new record into the CUSTOMERS table. Which two commands can be used to create
new rows?
INSERT, CREATE
MERGE, CREATE
![Page 1546: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1546.jpg)
INSERT, MERGE (*)
INSERT, UPDATE
Test: Quiz: Case and Character Manipulation
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Case and Character Manipulation
(Answer all questions in this section)
1. Identify the output from the following SQL statement:
SELECT RPAD('SQL',6, '*') FROM DUAL
Mark for Review
(1) Points
******SQL
***SQL
SQL*** (*)
![Page 1547: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1547.jpg)
SQL******
Correct
2. Which of the following SQL statements would correctly return a song title identified in the database
as "All These Years"? Mark for Review
(1) Points
WHERE title CONTAINS 'Years';
WHERE title LIKE LOWER('all these years');
WHERE title IN('All', 'These', 'Years');
WHERE title LIKE INITCAP('%all these years'); (*)
Incorrect. Refer to Section 1
3. Which character manipulation function always returns a numerical value? Mark for Review
(1) Points
![Page 1548: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1548.jpg)
TRIM
LPAD
LENGTH (*)
SUBSTR
Incorrect. Refer to Section 1
4. Which query would return a user password combining the ID of an employee and the first 4
characters of the last name? Mark for Review
(1) Points
SELECT CONCAT (employee_id, SUBSTR(last_name,4,1))
AS "User Passwords"
FROM employees
SELECT CONCAT (employee_id, INSTR(last_name,4,1))
AS "User Passwords"
FROM employees
![Page 1549: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1549.jpg)
SELECT CONCAT (employee_id, INSTR(last_name,1,4))
AS "User Passwords"
FROM employees
SELECT CONCAT (employee_id, SUBSTR(last_name,1,4))
AS "User Passwords"
FROM employees
(*)
Incorrect. Refer to Section 1
5. Which query selects the first names of the DJ On Demand clients who have a first name beginning
with "A"? Mark for Review
(1) Points
SELECT UPPER(first_name)
FROM d_clients
WHERE first_name LIKE %a%
SELECT UPPER(first_name)
FROM d_clients
![Page 1550: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1550.jpg)
WHERE first_name LIKE '%a%'
SELECT UPPER(first_name)
FROM d_clients
WHERE first_name LIKE 'a%'
SELECT UPPER(first_name)
FROM d_clients
WHERE LOWER(first_name) LIKE 'a%'
(*)
Incorrect. Refer to Section 1
6. Single row functions may be used in ______, _______ and _______ clauses. (Choose two correct
answers) Mark for Review
(1) Points
(Choose all correct answers)
SELECT, FROM, ALWAYS
![Page 1551: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1551.jpg)
FROM, SELECT, ORDERS
WHERE, DECODE, ORDER BY (*)
SELECT, WHERE, ORDER BY (*)
Incorrect. Refer to Section 1
7. Which of the following are types of SQL functions? (Choose two correct answers.) Mark for Review
(1) Points
(Choose all correct answers)
Multi-Row Functions (*)
Column-Row Functions
Single-Row Functions (*)
Many-to-Many Functions
Incorrect. Refer to Section 1
![Page 1552: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1552.jpg)
8. What does the following SQL SELECT statement return?
SELECT UPPER( SUBSTR('Database Programming', INSTR('Database Programming','P'),20))
FROM dual;
Mark for Review
(1) Points
Programming
PROGRAMMING (*)
Database
DATABASE
Incorrect. Refer to Section 1
9. Character functions accept character arguments and only return character values. True or False?
Mark for Review
(1) Points
True
![Page 1553: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1553.jpg)
False (*)
Correct
Test: Quiz: Number Functions
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Number Functions
(Answer all questions in this section)
1. ROUND and TRUNC functions can be used with which of the following Datatypes? Mark for Review
(1) Points
Dates and numbers (*)
Dates and characters
Numbers and characters
![Page 1554: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1554.jpg)
None of the above
Incorrect. Refer to Section 1
2. The answer to the following script is 456. True or False?
SELECT TRUNC(ROUND(456.98))
FROM dual
Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 1
3. Which number function may be used to determine if a value is odd or even? Mark for Review
(1) Points
MOD (*)
![Page 1555: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1555.jpg)
TRUNC
ROUND
BINARY
Incorrect. Refer to Section 1
4. If hire_date has a value of '03-July-03', then what is the output from this code?
SELECT ROUND(hire_date, 'Year')
FROM employees;
Mark for Review
(1) Points
01-JAN-04 (*)
01-JAN-03
01-JUL-03
01-AUG-03
![Page 1556: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1556.jpg)
Incorrect. Refer to Section 1
5. What is the result of the following SQL Statement:
SELECT ROUND(45.923,-1)
FROM DUAL; Mark for Review
(1) Points
46
45.9
50 (*)
None of the above
Correct.
Test: Quiz: Date Functions
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
![Page 1557: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1557.jpg)
Date Functions
(Answer all questions in this section)
1. Which query would return a whole number if the sysdate is 26-MAY-04? Mark for Review
(1) Points
SELECT TRUNC(MONTHS_BETWEEN(SYSDATE,'19-MAR-79') /12)
AS YEARS
FROM DUAL;
(*)
SELECT TRUNC(YEARS_BETWEEN(SYSDATE,'19-MAR-79') /12)
AS YEARS
FROM DUAL;
SELECT MONTHS_BETWEEN(SYSDATE,'19-MAR-79') /12
AS YEARS
FROM DUAL;
None of the above
![Page 1558: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1558.jpg)
Incorrect. Refer to Section 1
2. Round and Trunc can be used on Date datatypes. True or False? Mark for Review
(1) Points
True (*)
False
3. What is the result of the following query?
SELECT ADD_MONTHS ('11-JAN-94',6)
FROM dual;
Mark for Review
(1) Points
17-Jan-04
11-Jan-95
11-Jul-94 (*)
17-Jul-94
![Page 1559: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1559.jpg)
4. What is the result of the following query?
SELECT ADD_YEARS ('11-JAN-94',6)
FROM dual;
Mark for Review
(1) Points
This in not a valid SQL statement. (*)
11-Jul-95
11-Jan-00
11-Jul-00
5. What function would you use to return the highest date in a month? Mark for Review
(1) Points
FINAL_DAY
END_DAY
HIGHEST_DAY
![Page 1560: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1560.jpg)
LAST_DAY (*)
6. If hire_date has a value of '03-July-03', then what is the output from this code?
SELECT ROUND(hire_date, 'Year') FROM employees; Mark for Review
(1) Points
01-JAN-04 (*)
01-JAN-03
01-JUL-03
01-AUG-03
Test: Quiz: Conversion Functions
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Conversion Functions
(Answer all questions in this section)
![Page 1561: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1561.jpg)
1. You need to display the HIRE_DATE values in this format:
25th of July 2002.
Which SELECT statement would you use?
Mark for Review
(1) Points
SELECT enroll_date(hire_date, 'DDspth "of" Month YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'ddth "of" Month YYYY')
FROM employees;
(*)
SELECT TO_CHAR(hire_date, 'DDTH "of" Month YYYY')
FROM employees;
SELECT TO_CHAR(hire_date, 'DDspth 'of' Month RRRR')
FROM employees;
![Page 1562: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1562.jpg)
Incorrect. Refer to Section 2
2. Which statement will return the salary of e.g. 6000 from the Employees table in the following
format $6000.00? Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$99999.00') SALARY
FROM employees
(*)
SELECT TO_CHAR(salary, '99999.00') SALARY
FROM employees
SELECT TO_CHAR(salary, '$99999') SALARY
FROM employees
SELECT TO_CHAR(sal, '$99999.00') SALARY
FROM employees
3. The following script will run successfully. True or False?
![Page 1563: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1563.jpg)
SELECT TO_CHAR(TO_DATE(“25-DEC-04” ,'dd-MON-yy'))
FROM dual
Mark for Review
(1) Points
True
False (*)
Correct
4. A table has the following definition:
EMPLOYEES(
EMPLOYEE_ID NUMBER(6) NOT NULL,
LAST_NAME VARCHAR2(10) NOT NULL,
MANAGER_ID VARCHAR2(6))
and contains the following rows:
(1001, 'Bob Bevan', '200')
(200, 'Natacha Hansen', null)
Will the following query work:?
SELECT *
![Page 1564: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1564.jpg)
FROM emps
WHERE id = manager;
Mark for Review
(1) Points
No, because the WHERE-clause will not find any matching data
No, because the datatypes of ID and MANAGER are different.
Yes, Oracle will perform implicit datatype conversion. (*)
No. You will have to re-write the statement and perform explicit datatype conversion.
5. Which statement is true about SQL functions? Mark for Review
(1) Points
Functions can convert values or text to another data type.
Functions can round a number to a specified decimal place.
Functions can convert upper case characters to lower case characters.
a, b and c are true. (*)
![Page 1565: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1565.jpg)
None of the above statements are true.
Incorrect. Refer to Section 2
6. Sysdate is 12-MAY-2004.
You need to store the following date: 7-DEC-89
Which statement about the date format for this value is true? Mark for Review
(1) Points
Both the YY and RR date formats will interpret the year as 1989.
Both the YY and RR date formats will interpret the year as 2089.
The RR date format will interpret the year as 1989, and the YY date format will interpret the year as
2089. (*)
The RR date format will interpret the year as 2089, and the YY date format will interpret the year as
1989.
Incorrect. Refer to Section 2
![Page 1566: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1566.jpg)
Test: Quiz: Null Functions
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Null Functions
(Answer all questions in this section)
1. With the following data in Employees (last_name, commission_pct, manager_id) what is the result
of the following statement?
DATA:
King,null,null
Kochhar, null,100
Vargas, null, 124
Zlotkey,.2, 100
SELECT last_name, NVL2(commission_pct, manager_id, -1) comm
FROM employees ;
Mark for Review
(1) Points
King, -1
Kochhar, -1
Vargas, -1
![Page 1567: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1567.jpg)
Zlotkey, -100
Statement will fail.
King, -1
Kochhar, 100
Vargas, 124
Zlotkey, .2
King, -1
Kochhar, -1
Vargas, -1
Zlotkey, 100
(*)
2. If quantity is a number datatype, what is the result of this statement?
SELECT NVL(200/quantity, 'zero') FROM inventory;
Mark for Review
(1) Points
zero
![Page 1568: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1568.jpg)
ZERO
The statement fails (*)
Null
Incorrect. Refer to Section 2
3. Which function compares two expressions? Mark for Review
(1) Points
NVL
NULLIF (*)
NVL2
NULL
Correct
![Page 1569: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1569.jpg)
4. Consider the following data in the Employees table:
last_name commission_pct manager_id
King null null
Kochhar null 100
Vargas null 124
Zlotkey .2 100
What is the result of the following statement:
SELECT last_name, COALESCE(commission_pct, manager_id, -1) comm
FROM employees ;
Mark for Review
(1) Points
Statement will fail
King, -1
Kochhar, 100
Vargas, 124
Zlotkey, .2
(*)
King, -1
Kochhar, 100
Vargas, 124
Zlotkey, 100
![Page 1570: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1570.jpg)
King, null
Kochhar, 100
Vargas, 124
Zlotkey, .2
5. The following statement returns 0 (zero). True or False?
SELECT 121/NULL
FROM dual;
Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 2
Test: Quiz: Conditional Expressions
![Page 1571: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1571.jpg)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Conditional Expressions
(Answer all questions in this section)
1. Which of the following is a conditional expression used in SQL? Mark for Review
(1) Points
CASE (*)
DESCRIBE
WHERE
NULLIF
Incorrect. Refer to Section 2
2. For the given data from Employees (last_name, manager_id) what is the result of the following
statement:
DATA:
King, null
![Page 1572: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1572.jpg)
Kochhar, 100
De Haan, 100
Hunold, 102
Ernst, 103
SELECT last_name,
DECODE(manager_id, 100, 'King', 'A N Other')
FROM employees
Mark for Review
(1) Points
King, Null
Kochhar, King
De Haan, King
Hunold, A N Other
Ernst, A N Other
King, A N Other
Kochhar, King
De Haan, King
Hunold, A N Other
Ernst, A N Other
(*)
![Page 1573: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1573.jpg)
Invalid statement.
King, A N Other
Kochhar, King
De Haan, King
Hunold, Kochhar
Ernst, De Haan
3. CASE and DECODE evaluate expressions in a similar way to IF-THEN-ELSE logic. However, DECODE is
specific to Oracle syntax. True or False? Mark for Review
(1) Points
True (*)
False
Correct
4. Which statement will return a listing of last names, salaries and a rating of 'Low', 'Medium', 'Good'
or 'Excellent' depending on the salary value? Mark for Review
(1) Points
![Page 1574: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1574.jpg)
SELECT last_name,salary,
(CASE WHEN salary<5000 THEN 'Low'
WHEN salary<10000 THEN 'Medium'
WHEN salary<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
(*)
SELECT last_name,salary,
(CASE WHEN salary>5000 THEN 'Low'
WHEN salary>10000 THEN 'Medium'
WHEN salary>20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
SELECT last_name,sal,
(CASE WHEN sal<5000 THEN 'Low'
WHEN sal<10000 THEN 'Medium'
WHEN sal<20000 THEN 'Good'
ELSE 'Excellent'
![Page 1575: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1575.jpg)
END) qualified_salary
FROM employees;
SELECT last_name,salary,
(RATING WHEN salary<5000 THEN 'Low'
WHEN salary<10000 THEN 'Medium'
WHEN salary<20000 THEN 'Good'
ELSE 'Excellent'
END) qualified_salary
FROM employees;
Test: Quiz: Cartesian Product and the Join Operations
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Cartesian Product and the Join Operations
(Answer all questions in this section)
1. If table A has 10 rows and table B has 5 rows, how many rows will be returned if you perform an
equi-join on those two tables? Mark for Review
(1) Points
![Page 1576: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1576.jpg)
50
It depends on the data found in the two tables. (*)
5
10
2. When must column names be prefixed by table names in JOIN syntax? Mark for Review
(1) Points
When more than two tables participate in the join.
Only when query speed and database performance is a concern.
When the same column name appears in more than one table of the query. (*)
Never.
Correct
3. Will the following statement work?
![Page 1577: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1577.jpg)
SELECT department_name, last_name
FROM employees, departments
WHERE department_id = department_id;
Mark for Review
(1) Points
No, Oracle will return a column ambiguously defined error. (*)
No, Oracle will not allow joins in the Where clause.
Yes, Oracle will resolve which department_id colum comes from which table.
Yes, there are no syntax errors in the statement.
4. What is the result of a query that selects from two tables but includes no join condition? Mark for
Review
(1) Points
A Cartesian product. (*)
A selection of matched rows from both tables.
A Syntax error.
A selection of rows from the first table only.
![Page 1578: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1578.jpg)
Incorrect. Refer to Section 3
5. Oracle proprietary JOINS can use the WHERE clause for conditions other than the join-condition.
True or False? Mark for Review
(1) Points
True (*)
False
6. If table A has 10 rows and table B has 5 rows, how many rows will be returned if you perform a
cartesian join on those two tables? Mark for Review
(1) Points
5
50 (*)
10
15
![Page 1579: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1579.jpg)
Test: Quiz: Nonequijoins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Nonequijoins
(Answer all questions in this section)
1. Which statement about joining tables with a non-equijoin is false? Mark for Review
(1) Points
A WHERE clause must specify a column in one table that is compared to a column in the second table
(*)
The number of join conditions required is always one less than the number of tables being joined
The columns being joined must have compatible data types
None of the above
Correct
![Page 1580: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1580.jpg)
2. The following statement is an example of a nonequi-join.
SELECT e.last_name, e.salary, j.grade_level
FROM employees e, job_grades j
WHERE e.salary
BETWEEN j.lowest_sal AND j.highest_sal;
True or False?
Mark for Review
(1) Points
True (*)
False
3. Which of the following operators is/are typically used in a nonequijoin? Mark for Review
(1) Points
NOT
OR
IN
>=, <=, BETWEEN ...AND (*)
![Page 1581: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1581.jpg)
Incorrect. Refer to Section 3
Test: Quiz: Outer Joins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Outer Joins
(Answer all questions in this section)
1. To perform a valid outer join between DEPARMENTS and EMPLOYEES to list departments without
employees select the correct WHERE clause for the following select statement:
SELECT d.department_name, e.last_name
FROM employees e, departments d
WHERE
Mark for Review
(1) Points
e.department_id(+) = d.department_id (*)
![Page 1582: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1582.jpg)
e.department_id(+) = d.department_id(+)
e.department_id = d.department_id(+)
e.department_id = d.department_id
2. The ID column in the CLIENT table that corresponds to the CLIENT_ID column of the ORDER table
contains null values for rows that need to be displayed. Which type of join should you use to display the
data? Mark for Review
(1) Points
Equijoin
Self join
Outer join (*)
Nonequi-Join
Incorrect. Refer to Section 3
3. The following is a valid outer join statement:
SELECT c.country_name, d.department_name
![Page 1583: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1583.jpg)
FROM countries c, departments d
WHERE c.country_id (+) = d.country_id (+)
True or False?
Mark for Review
(1) Points
True
False (*)
4. Which symbol is used to perform an outer join? Mark for Review
(1) Points
*
||
(+) (*)
#
![Page 1584: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1584.jpg)
Correct
Test: Quiz: Self Joins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Self Joins
(Answer all questions in this section)
1. Which of the following database design concepts is implemented with a self join? Mark for Review
(1) Points
Non-Transferability
Recursive Relationship (*)
Supertype
Arc
Correct
![Page 1585: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1585.jpg)
2. Which select statement will return the last name and hire data of an employee and his/ her
manager for employees that started in the company before their managers? Mark for Review
(1) Points
SELECT w.last_name, w.hire_date, m.last_name, m.hire_date
FROM employees w , employees m
WHERE w.manager_id != m.employee_id AND w.hire_date < m.hire_date
SELECT w.last_name, w.hire_date, m.last_name, m.hire_date
FROM employees w , employees m
WHERE w.manager_id = m.employee_id AND w.hire_date > m.hire_date
SELECT w.last_name, w.hire_date, m.last_name, m.hire_date
FROM employees w , employees w
WHERE w.manager_id = w.employee_id AND w.hire_date < w.hire_date
SELECT w.last_name, w.hire_date, m.last_name, m.hire_date
FROM employees w , employees m
WHERE w.manager_id = m.employee_id AND w.hire_date < m.hire_date
(*)
![Page 1586: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1586.jpg)
3. Which SELECT statement implements a self join ? Mark for Review
(1) Points
SELECT e.employee_id, m.manager_id
FROM employees e NATURAL JOIN employee m;
SELECT e.employee_id, m.manager_id
FROM employees e, employees m
WHERE m.employee_id = e.manager_id;
(*)
SELECT e.employee_id, m.manager_id
FROM employees e, manager m
WHERE e.employee_id = m.manager_id;
SELECT e.employee_id, m.manager_id
FROM employees e, departments m
WHERE e.employee_id = m.manager_id;
![Page 1587: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1587.jpg)
Incorrect. Refer to Section 3
Test: Quiz: Cross joins and Natural Joins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Cross joins and Natural joins
1. The ___________ join is the ANSI-standard syntax used to generate a Cartesian product. Mark for
Review
(1) Points
NATURAL
ALL
FULL
CROSS (*)
Incorrect. Refer to Section 4
![Page 1588: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1588.jpg)
2. The join column must be included in the select statement when you use the NATURAL JOIN clause.
True or False? Mark for Review
(1) Points
True
False (*)
3. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
No rows are returned as you entered wrong join-criteria
The table is joined to itself, one column to the next column, exhausting all possibilities
All rows that do not match in the WHERE clause are displayed
Incorrect. Refer to Section 4
4. A NATURAL JOIN is based on: Mark for Review
![Page 1589: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1589.jpg)
(1) Points
Columns with the same name and datatype (*)
Columns with the same name
Columns with the same datatype and width
Tables with the same structure
Incorrect. Refer to Section 4
Test: Quiz: Join Clauses
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Join Clauses
(Answer all questions in this section)
1. The following is a valid SQL statement.
SELECT e.employee_id, e.last_name, d.location_id, department_id
![Page 1590: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1590.jpg)
FROM employees e JOIN departments d
USING (department_id) ;
True or False?
Mark for Review
(1) Points
True (*)
False
2. The keywords JOIN _____________ should be used to join tables with the same column names but
different datatypes. Mark for Review
(1) Points
NATURAL ON
ON
WHEN
USING (*)
![Page 1591: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1591.jpg)
Correct
3. You can do nonequi-joins with ANSI-Syntax. True or False? Mark for Review
(1) Points
True (*)
False
4. 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 easily produces a Cartesian product between the tables in the statement
It permits columns that don?t have matching data types to be joined
It permits columns with different names to be joined (*)
![Page 1592: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1592.jpg)
Correct
5. Table aliases MUST be used with columns referenced in the JOIN USING clause. True or False? Mark
for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 4
Test: Quiz: Inner versus Outer Joins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Inner versus Outer Joins
(Answer all questions in this section)
1. Given the following descriptions of the employees and jobs tables, which of the following scripts will
display each employee's possible minimum and maximum salaries based on their job title?
![Page 1593: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1593.jpg)
EMPLOYEES Table:
Name Null? Type
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2 (20)
LAST_NAME NOT NULL VARCHAR2 (25)
EMAIL NOT NULL VARCHAR2 (25)
PHONE_NUMBER VARCHAR2 (20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2 (10)
SALARY NUMBER (8,2)
COMMISSION_PCT NUMBER (2,2)
MANAGER_ID NUMBER (6)
DEPARTMENT_ID NUMBER (4)
JOBS Table:
Name Null? Type
JOB_ID NOT NULL VARCHAR2 (10)
JOB_TITLE NOT NULL VARCHAR2 (35)
MIN_SALARY NUMBER (6)
MAX_SALARY NUMBER (6)
Mark for Review
(1) Points
![Page 1594: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1594.jpg)
SELECT e.first_name, e.last_name, e.job_id, j.min_salary, j.max_salary
FROM employees e
NATURAL JOIN jobs j
USING (job_id);
SELECT first_name, last_name, job_id, min_salary, max_salary
FROM employees
NATURAL JOIN jobs;
(*)
SELECT e.first_name, e.last_name, e.job_id, j.min_salary, j.max_salary
FROM employees e
NATURAL JOIN jobs j;
SELECT first_name, last_name, job_id, min_salary, max_salary
FROM employees e
FULL JOIN jobs j (job_id);
SELECT e.first_name, e.last_name, e.job_id, j.min_salary, j.max_salary
FROM employees e
NATURAL JOIN jobs j ON (e.job_title = j.job_title);
![Page 1595: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1595.jpg)
Correct
2. For which of the following tables will all the values be retrieved even if there is no match in the
other?
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
Mark for Review
(1) Points
employees (*)
department
both
Neither. the LEFT OUTER JOIN limits the value to the matching department id's.
Incorrect. Refer to Section 4
![Page 1596: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1596.jpg)
3. If you select rows from two tables (employees and departments) using an outer join, what will you
get? Use the code below to arrive at your answer:
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d
ON (e.department_id = d.department_id);
Mark for Review
(1) Points
All employees that do not have a department_id assigned to them
All employees including those that do not have a department_id assigned to them (*)
No employees as the statement will fail
None of the above
Incorrect. Refer to Section 4
4. The following statement is an example of what kind of join?
SELECT car.vehicle_id, driver.name
FROM car
LEFT OUTER JOIN driver ON (driver_id) ;
![Page 1597: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1597.jpg)
Mark for Review
(1) Points
Inner Join
Outer Join (*)
Equijoin
Optimal Join
Incorrect. Refer to Section 4
5. What is another name for a simple join or an inner join? Mark for Review
(1) Points
Nonequijoin
Equijoin (*)
Self Join
Outer Join
![Page 1598: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1598.jpg)
Incorrect. Refer to Section 4
6. Which syntax would be used to retrieve all rows in both the EMPLOYEES and DEPARTMENTS tables,
even when there is no match? Mark for Review
(1) Points
FULL OUTER JOIN (*)
LEFT OUTER JOIN AND RIGHT OUTER JOIN
FULL INNER JOIN
Use any equijoin syntax
Incorrect. Refer to Section 4
7. EMPLOYEES Table: Name Null? Type
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
DEPARTMENT_ID NUMBER (4)
![Page 1599: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1599.jpg)
DEPARTMENTS Table: Name Null? Type
DEPARTMENT_ID NOT NULL NUMBER 4
DEPARTMENT_NAME NOT NULL VARCHAR2(30)
MANAGER_ID NUMBER (6)
A query is needed to display each department and its manager name from the above tables. However,
not all departments have a manager but we want departments returned in all cases. Which of the
following SQL: 1999 syntax scripts will accomplish the task?
Mark for Review
(1) Points
SELECT d.department_id, e.first_name, e.last_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.employee_id = d.manager_id);
SELECT d.department_id, e.first_name, e.last_name
FROM employees e
LEFT OUTER JOIN departments d
WHERE (e.department_id = d.department_id);
SELECT d.department_id, e.first_name, e.last_name
FROM employees e
![Page 1600: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1600.jpg)
RIGHT OUTER JOIN departments d ON (e.employee_id = d.manager_id);
(*)
SELECT d.department_id, e.first_name, e.last_name
FROM employees e
FULL OUTER JOIN departments d ON (e.employee_id = d.manager_id);
SELECT d.department_id, e.first_name, e.last_name
FROM employees e, departments d
WHERE e.employee_id RIGHT OUTER JOIN d.manager_id;
Incorrect. Refer to Section 4
Test: Quiz: Group Functions
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
![Page 1601: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1601.jpg)
Group Functions
(Answer all questions in this section)
1. What two group functions can be used with any datatype? Mark for Review
(1) Points
STDDEV, VARIANCE
SUM, AVG
COUNT, SUM
MIN, MAX (*)
Incorrect. Refer to Section 5
2. Given the following data in the employees table (employee_id, salary, commission_pct)
DATA: (143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)
![Page 1602: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1602.jpg)
What is the result of the following statement:
SELECT SUM(commission_pct), COUNT(commission_pct)
FROM employees
WHERE employee_id IN( 143,144,149,174,176,178)
Mark for Review
(1) Points
SUM = 1.85 and COUNT = 6
SUM = 1.85 and COUNT = 4
SUM = .85 and COUNT = 6
SUM = .85 and COUNT = 4 (*)
3. The following statement will work even though it uses the same column with different GROUP
functions:
SELECT AVG(salary), MAX(salary), MIN(salary), SUM(salary)
FROM employees;
True or False?
Mark for Review
![Page 1603: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1603.jpg)
(1) Points
True (*)
False
4. You can use GROUP functions in all clauses of a SELECT statement. True or False? Mark for Review
(1) Points
True
False (*)
5. What would the following SQL statement return?
SELECT MAX(hire_date)
FROM employees;
Mark for Review
(1) Points
The hire date of the longest serving employee
The hire date of the newest employee (*)
![Page 1604: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1604.jpg)
The hire dates of all employees in ascending order
The hire dates of all employees
Correct
6. Given the following data in the employees table (employee_id, salary, commission_pct)
DATA: (143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)
What is the result of the following statement:
SELECT AVG(commission_pct)
FROM employees
WHERE employee_id IN( 143,144,149,174,176,178)
Mark for Review
(1) Points
![Page 1605: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1605.jpg)
This statement is invalid
0.2125 (*)
1.2125
0.0425
Test: Quiz: Count, Distinct, NVL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Count, Distinct, NVL
(Answer all questions in this section)
1. Using your existing knowledge of the employees table, would the following two statements produce
the same result?
SELECT COUNT(*)
FROM employees;
SELECT COUNT(commission_pct)
![Page 1606: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1606.jpg)
FROM employees;
Mark for Review
(1) Points
The second statement is invalid
The first statement is invalid
Yes
No (*)
2. To include null values in the calculations of a group function, you must: Mark for Review
(1) Points
Precede the group function name with NULL
Count the number of null values in that column using COUNT
Convert the null to a value using the NVL( ) function (*)
Group functions can never use null values
![Page 1607: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1607.jpg)
Correct
3. What would the following SQL statement return?
SELECT COUNT(DISTINCT salary)
FROM employees;
Mark for Review
(1) Points
The number of unique salaries in the employees table (*)
The total amount of salaries in the employees table
The total number of rows in the employees table
A listing of all unique salaries in the employees table
4. What would the following SQL statement return?
SELECT COUNT(first_name)
FROM employees;
Mark for Review
(1) Points
![Page 1608: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1608.jpg)
A listing of all non-null first names in the employees table
The total number of non-null first names in the employees table (*)
The total number of rows in the employees table
A listing of all unique first names in the employees table
Incorrect. Refer to Section 5
Test: Quiz: Group By and Having Clauses
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Group By and Having Clauses
(Answer all questions in this section)
1. How would you alter the following query to list only employees where more than one employee
exists with the same last_name:
SELECT last_name, COUNT(employee_id)
FROM EMPLOYEES
![Page 1609: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1609.jpg)
GROUP BY last_name;
Mark for Review
(1) Points
SELECT last_name, COUNT(employee_id)
FROM EMPLOYEES
WHERE COUNT(*) > 1
GROUP BY last_name
SELECT last_name, COUNT(last_name)
FROM EMPLOYEES
GROUP BY last_name
HAVING COUNT(last_name) > 1;
(*)
SELECT last_name, COUNT(last_name)
FROM EMPLOYEES
GROUP BY last_name
EXISTS COUNT(last_name) > 1;
SELECT employee_id, DISTINCT(last_name)
![Page 1610: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1610.jpg)
FROM EMPLOYEES
GROUP BY last_name
HAVING last_name > 1;
2. Which of the following SQL statements could display the number of people with the same last
name: Mark for Review
(1) Points
SELECT first_name, last_name, COUNT(employee_id)
FROM EMPLOYEES
GROUP BY last_name;
SELECT employee_id, COUNT(last_name)
FROM EMPLOYEES
GROUP BY last_name;
SELECT last_name, COUNT(last_name)
FROM EMPLOYEES
GROUP BY last_name;
(*)
![Page 1611: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1611.jpg)
SELECT employee_id, DISTINCT(last_name)
FROM EMPLOYEES
GROUP BY last_name;
Incorrect. Refer to Section 5
3. Is the following statement correct:
SELECT first_name, last_name, salary, department_id,
COUNT(employee_id)
FROM employees
WHERE department_id = 50
GROUP BY last_name, first_name, department_id;
Mark for Review
(1) Points
Yes
No, beause you cannot have a WHERE-clause when you use group functions.
No, because the statement is missing salary in the GROUP BY clause (*)
![Page 1612: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1612.jpg)
Yes, because Oracle will correct any mistakes in the statement itself
4. Read the following SELECT statement. Choose the column or columns that must be included in the
GROUP_BY clause.
SELECT COUNT(last_name), grade, gender
FROM STUDENTS
GROUP_BY ?????;
Mark for Review
(1) Points
last_name
last_name, grade
grade, gender (*)
last_name, gender
Correct
5. Is the following statement correct?
SELECT department_id, AVG(salary)
FROM employees;
![Page 1613: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1613.jpg)
Mark for Review
(1) Points
No, because a GROUP BY department_id clause is needed (*)
No, because the SELECT clause cannot contain both individual columns and group functions
No, because the AVG function cannot be used on the salary column
Yes
Incorrect. Refer to Section 5
6. The following is a valid statement:
SELECT MAX(AVG(salary))
FROM employees
GROUP BY department_id;
True or False?
Mark for Review
(1) Points
![Page 1614: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1614.jpg)
True (*)
False
Test: Quiz: Subqueries
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Subqueries
(Answer all questions in this section)
1. What will the following statement return:
SELECT last_name, salary
FROM employees
WHERE salary < (SELECT salary
FROM employees
WHERE employee_id = 103)
Mark for Review
(1) Points
![Page 1615: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1615.jpg)
A list of last_names and salaries of employees that makes more than employee 103
A list of last_names and salaries of employees that makes less than employee 103 (*)
A list of first_names and salaries of employees making less than employee 103
Nothing. It is an invalid statement.
2. Which of the following statements is a true guideline for using subqueries? Mark for Review
(1) Points
Do not enclose the subquery in parentheses.
Place the subquery on the left side of the comparison condition.
The outer and inner queries can reference than one table. They can get data from different tables. (*)
Only one WHERE clause can be used for a SELECT statement, and if specified, it must be the outer
query.
Correct
3. What will the following statement return:
![Page 1616: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1616.jpg)
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary)
FROM employees
GROUP BY department_id);
Mark for Review
(1) Points
Nothing. It is an invalid statement. (*)
A list of last_names and salaries of employees
A list of first_names and salaries of employees in Department 50
A list of last_names and salaries of employees grouped by department_id.
4. Subqueries can only be placed in the WHERE clause. True or False? Mark for Review
(1) Points
True
False (*)
![Page 1617: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1617.jpg)
Test: Quiz: Single-Row Subqueries
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Single-Row Subqueries
(Answer all questions in this section)
1. Single row subqueries may not include this operator: Mark for Review
(1) Points
ALL (*)
=
<>
>
Incorrect. Refer to Section 6
![Page 1618: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1618.jpg)
2. Subqueries are limited to four per SQL transaction. True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 6
3. In a non-correlated subquery, the outer query always executes prior to the inner query's execution.
True or False? Mark for Review
(1) Points
True
False (*)
Correct
4. The result of this statement will be:
SELECT last_name, job_id, salary, department_id
![Page 1619: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1619.jpg)
FROM employees
WHERE job_id =
(SELECT job_id
FROM employees
WHERE employee_id = 141) AND department_id =
(SELECT department_id
FROM departments
WHERE location_id =1500)
Mark for Review
(1) Points
All employees from Location 1500 will be displayed
An error since you can?t get data from two tables in the same subquery
All employees with the department id of 141
Only the employees whose job id matches employee 141 and who work in location 1500 (*)
Correct
5. If the subquery returns no rows will the outer query return any values? Mark for Review
![Page 1620: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1620.jpg)
(1) Points
No, because you are not allowed to not return any rows from a subquery
Yes. It will just run and ignore the subquery
No, because the subquery will be treated like a null value. (*)
Yes, Oracle will find the nearest value and fix rewrite your statement implicitly when you run it
Test: Quiz: Multiple-Row Subqueries
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Multiple-Row Subqueries
(Answer all questions in this section)
1. Group functions, such as HAVING and GROUP BY, can be used in multiple-row subqueries. True or
False? Mark for Review
(1) Points
True (*)
![Page 1621: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1621.jpg)
False
Correct
2. When a multiple-row subquery uses the NOT IN (<>ALL) operator, if one of the values returned by
the inner query is a null value, the entire query returns: Mark for Review
(1) Points
A list of Nulls
All rows that were selected by the inner query including the null value(s)
All rows, minus the null value(s), that were selected by the inner query
no rows returned (*)
Incorrect. Refer to Section 6
3. The salary column of the f_staffs table contains the following values:
4000
5050
6000
![Page 1622: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1622.jpg)
11000
23000
Which of the following statements will return the last_name and first_name of those employees who
earn more than 5000.
Mark for Review
(1) Points
SELECT last_name, first_name
FROM f_staffs
WHERE salary = (SELECT salary FROM f_staffs WHERE salary > 5000);
SELECT last_name, first_name
FROM f_staffs
WHERE salary = (SELECT salary FROM f_staffs WHERE salary < 5000);
SELECT last_name, first_name
FROM f_staffs
WHERE salary IN (SELECT salary FROM f_staffs WHERE salary > 5000);
(*)
SELECT last_name, first_name
FROM f_staffs
WHERE salary IN (SELECT last_name, first_name FROM f_staffs WHERE salary < 5000);
![Page 1623: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1623.jpg)
Correct
4. In a subquery the ALL operator compares a value to every value returned by the inner query. True or
False? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 6
5. Group functions can be used in subqueries even though they may return many rows. True or False?
Mark for Review
(1) Points
True (*)
False
![Page 1624: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1624.jpg)
Incorrect. Refer to Section 6
6. The SQL multiple-row subquery extends the capability of the single-row syntax through the use of
what three comparison operators? Mark for Review
(1) Points
IN, ANY and EQUAL
IN, ANY and ALL (*)
IN, ANY and EVERY
IN, ALL and EVERY
Correct
7. There can be more than one subquery returning information to the outer query. True or False?
Mark for Review
(1) Points
True (*)
![Page 1625: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1625.jpg)
False
Correct
8. Multiple-row subqueries must have NOT, IN or ANY in the WHERE clause of the inner query. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
Test: Quiz: Insert Statement
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
![Page 1626: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1626.jpg)
Insert Statement
(Answer all questions in this section)
1. When inserting a new row the null keyword can be included in the values list for any null column.
True or False? Mark for Review
(1) Points
True (*)
False
Correct
2. Insert statements can be combined with subqueries to create more than one row per statement.
True or False? Mark for Review
(1) Points
True (*)
False
3. If the employees table have 7 rows how many rows are inserted into the copy_emps table with the
following statement:
![Page 1627: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1627.jpg)
INSERT INTO copy_emps (employee_id, first_name, last_name, salary, department_id)
SELECT employee_id, first_name, last_name, salary, department_id
FROM employees
Mark for Review
(1) Points
No rows, as you cannot use subqueries in an insert statement.
7 rows, as there is no WHERE-clause on the subquery. (*)
No rows, as the select statement is invalid.
10 rows will be created.
4. What is the quickest way to use todays date when you are creating a new row? Mark for Review
(1) Points
Simply write todays date in the format of 'dd-mon-rr'.
Simply use the keyword DATE in the insert statement.
Use the SYSDATE function. (*)
Use the TODAYS_DATE function.
![Page 1628: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1628.jpg)
5. Which of the following statements will add a new customer to the customers table in the Global
Fast Foods database? Mark for Review
(1) Points
INSERT IN customers (id, first_name, last_name, address, city, state, zip, phone_number);
INSERT INTO customers (id, first_name, last_name, address, city, state, zip, phone_number)
VALUES ("145", 'Katie', 'Hernandez', '92 Chico Way', 'Los Angeles', 'CA', "98008", "8586667641");
INSERT INTO customers (id, first_name, last_name, address, city, state, zip, phone_number)
VALUES (145, 'Katie', 'Hernandez', '92 Chico Way', 'Los Angeles', 'CA', 98008, 8586667641);
(*)
INSERT INTO customers (id 145, first_name 'Katie', last_name 'Hernandez', address '92 Chico Way',
city 'Los Angeles', state 'CA', zip 98008, phone_number 8586667641);
Correct
![Page 1629: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1629.jpg)
6. To return a table summary on the customers table, which of the following is correct? Mark for
Review
(1) Points
SHOW customers, or SEE customers
DISTINCT customers, or DIST customers
DESCRIBE customers, or DESC customers (*)
DEFINE customers, or DEF customers
Incorrect. Refer to Section 7
7. Is it possible to insert more than one row at a time using an INSERT statement with a VALUES
clause? Mark for Review
(1) Points
No, you can only create one row at a time when using the VALUES clause. (*)
Yes, you can just list as many rows as you want, just remember to separate the rows with commas.
No, there is no such thing as INSERT …. VALUES.
![Page 1630: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1630.jpg)
8. When inserting rows into a table all columns must be given values. True or False? Mark for Review
(1) Points
True
False (*)
9. DML is an acronym that stands for: Mark for Review
(1) Points
Debit Markup Language
Don't Manipulate Language
Data Markup Language
Data Manipulation Language (*)
Incorrect. Refer to Section 7
![Page 1631: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1631.jpg)
Test: Quiz: Updating Column Values and Deleting Rows
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Updating Column Values and Deleting Rows
(Answer all questions in this section)
1. Assuming there are no Foreign Keys on the EMPLOYEES table, if the following subquery returns one
row, how many rows will be deleted from the EMPLOYEES table?
DELETE FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name LIKE '%Public%');
Mark for Review
(1) Points
No rows will be deleted.
One row will be deleted, as the subquery only returns one row.
All the rows in the EMPLOYEES table with department_ids matching the department_id returned by
the subquery. (*)
![Page 1632: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1632.jpg)
All rows in the EMPLOYEES table will be deleted, regardless of their department_id.
2. How many rows will be deleted from the employees table with the following statement?
DELETE FROM employees
WHERE last_name = 'king';
Mark for Review
(1) Points
All the rows in the employees table will be deleted.
No rows will be deleted, as no employees match the WHERE-clause. (*)
One will will be deleted, as there exists one employee called King.
All rows with last_name = 'King' will be deleted.
3. Using your knowledge of the employees table, what would be the result of the following statement:
DELETE FROM employees; Mark for Review
(1) Points
Nothing, no data will be changed.
All rows in the employees table will be deleted if there are no constraints on the table. (*)
![Page 1633: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1633.jpg)
The first row in the employees table will be deleted.
Deletes employee number 100.
4. Is the following statement valid, i.e. is it allowed to update rows in one table, based on a subquery
from another table?
UPDATE copy_emp
SET department_id = (SELECT department_id
FROM employees
WHERE employee_id = 100)
WHERE job_id = (SELECT job_id
FROM employees
WHERE employee_id = 200);
Mark for Review
(1) Points
Yes, this is a perfectly valid statement. (*)
The statement will fail, because the subqueries are returning data from different rows
No, this will not work
No, this statement will return an error.
![Page 1634: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1634.jpg)
5. Which of the following statements best describes what will happen to the student table in this SQL
statement?
UPDATE students
SET lunch_number =
(SELECT lunch_numer
FROM students
WHERE student_id = 17)
WHERE student_id = 19;
Mark for Review
(1) Points
The statement updates the student_table by replacing student id 19’s lunch number with student id
17’s lunch number. (*)
Inserts a new row into the students table.
Does nothing, the as you cannot use subqueries in update statements.
Deletes student 17's lunch_number and inserts a new value from student 19.
Correct
6. To change an existing row in a table, you can use the UPDATE and INSERT statements. True or False?
Mark for Review
(1) Points
![Page 1635: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1635.jpg)
True
False (*)
Correct
Test: Quiz: Default Values and the Merge Statement
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Default Values and the Merge Statement
(Answer all questions in this section)
1. The MERGE function combines the: Mark for Review
(1) Points
CREATE and UPDATE commands
INSERT and UPDATE commands (*)
![Page 1636: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1636.jpg)
ALTER and UPDATE commands
all of the above
Incorrect. Refer to Section 7
2. The DEFAULT keyword can be used in the following statements:
Mark for Review
(1) Points
INSERT and UPDATE (*)
INSERT and DELETE
DELETE and UPDATE
All of the above
3. If a default value was set for a null column, Oracle sets the column to the default value. However, if
no default value was set when the column was created, Oracle inserts an empty space. True or False?
Mark for Review
(1) Points
True
False (*)
![Page 1637: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1637.jpg)
Correct
4. Which statement below will not insert a row of data onto a table? Mark for Review
(1) Points
INSERT INTO student_table (id, lname, fname, lunch_num)
VALUES (143354, 'Roberts', 'Cameron', 6543);
INSERT INTO student_table
VALUES (143354, 'Roberts', 'Cameron', 6543);
INSERT INTO student_table (id, lname, fname, lunch_num)
VALUES (143352, 'Roberts', 'Cameron', DEFAULT);
INSERT INTO (id, lname, fname, lunch_num)
VALUES (143354, 'Roberts', 'Cameron', 6543);
(*)
Incorrect. Refer to Section 7
![Page 1638: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1638.jpg)
5. The MERGE statement can be used to update rows in one table based on values in another table
and if the update fails, then the rows will automatically be inserted instead. True or False? Mark for
Review
(1) Points
True (*)
False
6. In developing the Employees table, you create a column called hire_date. You assign the hire_date
column a DATE datatype with a DEFAULT value of 0 (zero). A user can come back later and enter the
correct hire_date. This is __________. Mark for Review
(1) Points
A great idea. When a new employee record is entered, if no hire_date is specified, the 0 (zero) will be
automatically specified.
A great idea. When new employee records are entered, they can be added faster by allowing the 0's
(zeroes) to be automatically specified.
Both a and b are correct.
A bad idea. The default value must match the DATE datatype of the column. (*)
![Page 1639: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1639.jpg)
Incorrect. Refer to Section 7
Page 1 of 1
![Page 1640: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1640.jpg)
![Page 1641: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1641.jpg)
![Page 1642: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1642.jpg)
![Page 1643: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1643.jpg)
Section 1 Lesson 1
(Answer all questions in this section)
1. You need to return a portion of each employee's last name, beginning with the first character up to
the fifth character. Which character function should you use? Mark for Review
(1) Points
INSTR
![Page 1644: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1644.jpg)
TRUNC
SUBSTR (*)
CONCAT
Incorrect. Refer to Section 1
2. What will the following SQL statement display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column
labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the
column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, left-
padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Incorrect. Refer to Section 1
3. Which SQL function can be used to remove heading or trailing characters (or both) from a character
string? Mark for Review
(1) Points
LPAD
CUT
![Page 1645: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1645.jpg)
NVL2
TRIM (*)
Incorrect. Refer to Section 1
4. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employees;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEES table.
The email address of each employee in the EMPLOYEES table.
The number of characters for each value in the EMAIL column in the EMPLOYEES table. (*)
The maximum number of characters allowed in the EMAIL column.
Correct
5. You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
1
![Page 1646: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1646.jpg)
2
13 (*)
17
Incorrect. Refer to Section 1
6. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Incorrect. Refer to Section 1
7. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
![Page 1647: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1647.jpg)
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Incorrect. Refer to Section 1
Section 1 Lesson 2
(Answer all questions in this section)
8. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
![Page 1648: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1648.jpg)
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
9. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employees;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employees;
SELECT ROUND(hire_date, 'MON')
FROM employees;
SELECT TRUNC(hire_date, 'MI')
FROM employees;
Incorrect. Refer to Section 1 Lesson 3
10. Which two functions can be used to manipulate number or date column values, but NOT character
![Page 1649: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1649.jpg)
column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Incorrect. Refer to Section 1
Page 1 of 10
11. Which of the following SQL statements will correctly display the last name and the number of
weeks employed for all employees in department 90? Mark for Review
(1) Points
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;
![Page 1650: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1650.jpg)
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;
Incorrect. Refer to Section 1
12. You need to display the number of months between today's date and each employee's hiredate.
Which function should you use? Mark for Review
(1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Incorrect. Refer to Section 1
13. You want to create a report that displays all orders and their amounts that were placed during the
month of January. You want the orders with the highest amounts to appear first. Which query should
you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
![Page 1651: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1651.jpg)
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Incorrect. Refer to Section 1
14. You need to subtract three months from the current date. Which function should you use? Mark
for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
15. Which SELECT statement will return a numeric value? Mark for Review
(1) Points
![Page 1652: Oracle Mid Exam Totpart1](https://reader035.vdocuments.net/reader035/viewer/2022081416/5520c91d4979597a2f8b4eee/html5/thumbnails/1652.jpg)
SELECT SYSDATE + 600 / 24