1. est: Mid Term Exam Semester 2 – Part II
  2. Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
  3.         Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL.
  4.         Section 5
  5.                 1.      You use GROUPING function to:   Mark for Review
  6. (1) Points
  7.         Produce subtotal and cross-tabulated values
  8.         Identify the extra row values created by either a ROLLUP or CUBE operation (*)
  9.         Aggregate rows using SUM, MIN, MAX, and COUNT
  10. Correct         Correct
  11.                 2.      GROUPING SETS is another extension to the GROUP BY clause and is used to specify multiple groupings of data but provide a single result set. True or False?     Mark for Review
  12. (1) Points
  13.         True (*)
  14.         False
  15. Incorrect               Incorrect. Refer to Section 5 Lesson 2.
  16.                 3.      You use GROUPING function to ______ database rows from tabulated rows.  Mark for Review
  17. (1) Points
  18.         CREATE
  19.         DISTINGUISH (*)
  20.         COMPUTE
  21.         COUNT
  22. Incorrect               Incorrect. Refer to Section 5 Lesson 2.
  23.                 4.      CUBE will cross-reference the columns listed in the ______ clause to create a superset of groups.       Mark for Review
  24. (1) Points
  25.         GROUP BY (*)
  26.         WHERE
  27.         SELECT
  28. Correct         Correct
  29.                 5.      Group functions can be nested to a depth of?    Mark for Review
  30. (1) Points
  31.         Three
  32.         Four
  33.         Two (*)
  34.         Group functions cannot be nested.
  35. Correct         Correct
  36.                 6.      The PRODUCTS table contains these columns:
  37. PROD_ID NUMBER(4)
  38. PROD_NAME VARCHAR(20)
  39. PROD_CAT VARCHAR2(15)
  40. PROD_PRICE NUMBER(5)
  41. PROD_QTY NUMBER(4)
  42. You need to identify the minimum product price in each product category.
  43. Which statement could you use to accomplish this task?
  44.         Mark for Review
  45. (1) Points
  46.         SELECT prod_cat, MIN (prod_price)
  47. FROM products
  48. GROUP BY prod_price;
  49.         SELECT prod_cat, MIN (prod_price)
  50. FROM products
  51. GROUP BY prod_cat;
  52. (*)
  53.         SELECT MIN (prod_price), prod_cat
  54. FROM products
  55. GROUP BY MIN (prod_price), prod_cat;
  56.         SELECT prod_price, MIN (prod_cat)
  57. FROM products
  58. GROUP BY prod_cat;
  59. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  60.                 7.      Evaluate this SELECT statement:
  61. SELECT COUNT(emp_id), mgr_id, dept_id
  62. FROM employees
  63. WHERE status = ‘I’
  64. GROUP BY dept_id
  65. HAVING salary > 30000
  66. ORDER BY 2;
  67. Why does this statement return a syntax error?
  68.         Mark for Review
  69. (1) Points
  70.         MGR_ID must be included in the GROUP BY clause. (*)
  71.         The HAVING clause must specify an aggregate function.
  72.         A single query cannot contain a WHERE clause and a HAVING clause.
  73.         The ORDER BY clause must specify a column name in the EMPLOYEE table.
  74. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  75.                 8.      Which statement about group functions is true?  Mark for Review
  76. (1) Points
  77.         Group functions ignore null values. (*)
  78.         Group functions can only be used in a SELECT list.
  79.         Group functions can be used in a WHERE clause.
  80.         A query that includes a group function in the SELECT list must include a GROUP BY clause.
  81. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  82.                 9.      The EMPLOYEES table contains the following columns:
  83. EMPLOYEE_ID NUMBER(10) PRIMARY KEY
  84. LAST_NAME VARCHAR2(20)
  85. FIRST_NAME VARCHAR2(20)
  86. DEPARTMENT VARCHAR2(20)
  87. HIRE_DATE DATE
  88. SALARY NUMBER(10)
  89. 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.
  90. Which of the following SELECT statements will accomplish this task?
  91.         Mark for Review
  92. (1) Points
  93.         SELECT employee_id, last_name, salary
  94. FROM employees
  95. WHERE salary > 40000
  96. AND hire_date =
  97.    (SELECT hire_date
  98.     FROM employees
  99.     WHERE (sysdate-hire_date) / 365 > 1);
  100.         SELECT employee_id, last_name, hire_date, salary
  101. FROM employees
  102. WHERE salary > 40000 AND hire_date =
  103.     (SELECT hire_date
  104.     FROM employees
  105.     WHERE (sysdate-hire_date) / 365 > 1);
  106.         SELECT employee_id, last_name, hire_date, salary
  107. FROM employees
  108. WHERE salary > 40000
  109. AND (sysdate-hire_date) / 365 > 1;
  110. (*)
  111.         SELECT employee_id, last_name, salary
  112. FROM employees
  113. WHERE salary > 40000
  114. AND hire_date IN (sysdate-hire_date) / 365 > 1);
  115. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  116.                 10.     What will the following SQL Statement do?
  117. SELECT job_id, COUNT(*)
  118. FROM employees
  119. GROUP BY job_id;
  120.         Mark for Review
  121. (1) Points
  122.         Displays all the employees and groups them by job.
  123.         Displays each job id and the number of people assigned to that job id. (*)
  124.         Displays only the number of job_ids.
  125.         Displays all the jobs with as many people as there are jobs.
  126. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  127. Section 5
  128.                 11.     Which statement about the GROUP BY clause is true?      Mark for Review
  129. (1) Points
  130.         To exclude rows before dividing them into groups using the GROUP BY clause, you should use a WHERE clause. (*)
  131.         You can use a column alias in a GROUP BY clause.
  132.         By default, rows are not sorted when a GROUP BY clause is used.
  133.         You must use the HAVING clause with the GROUP BY clause.
  134. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  135.                 12.     The PLAYERS and TEAMS tables contain these columns:
  136. PLAYERS
  137. PLAYER_ID NUMBER NOT NULL, PRIMARY KEY
  138. LAST_NAME VARCHAR2 (30) NOT NULL
  139. FIRST_NAME VARCHAR2 (25) NOT NULL
  140. TEAM_ID NUMBER
  141. POSITION VARCHAR2 (25)
  142. TEAMS
  143. TEAM_ID NUMBER NOT NULL, PRIMARY KEY
  144. TEAM_NAME VARCHAR2 (25)
  145. You need to create a report that lists the names of each team with more than three goal keepers.
  146. Which SELECT statement will produce the desired result?
  147.         Mark for Review
  148. (1) Points
  149.         SELECT t.team_name, COUNT(p.player_id)
  150. FROM players p, teams t
  151. ON (p.team_id = t.team_id)
  152. WHERE UPPER(p.position) = ‘GOAL KEEPER’
  153. GROUP BY t.team_name;
  154.         SELECT t.team_name, COUNT(p.player_id)
  155. FROM players
  156. JOIN teams t ON (p.team_id = t.team_id)
  157. WHERE UPPER(p.position) = ‘GOAL KEEPER’
  158. HAVING COUNT(p.player_id) > 3;
  159.         SELECT t.team_name, COUNT(p.player_id)
  160. FROM players p, teams t
  161. ON (p.team_id = t.team_id)
  162. WHERE UPPER(p.position) = ‘GOAL KEEPER’
  163. GROUP BY t.team_name
  164. HAVING COUNT(p.player_id) > 3;
  165.         SELECT t.team_name, COUNT(p.player_id)
  166. FROM players p
  167. JOIN teams t ON (p.team_id = t.team_id)
  168. WHERE UPPER(p.position) = ‘GOAL KEEPER’
  169. GROUP BY t.team_name
  170. HAVING COUNT(p.player_id) > 3;
  171. (*)
  172. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  173.                 13.     The PAYMENT table contains these columns:
  174. PAYMENT_ID NUMBER(9) PK
  175. PAYMENT_DATE DATE
  176. CUSTOMER_ID NUMBER(9)
  177. Which SELECT statement could you use to display the number of times each customer payment was made between January 1, 2003 and June 30, 2003 ?
  178.         Mark for Review
  179. (1) Points
  180.         SELECT customer_id, COUNT(payment_id)
  181. FROM payment
  182. WHERE payment_date BETWEEN ’01-JAN-2003′ AND ’30-JUN-2003′
  183. GROUP BY customer_id;
  184. (*)
  185.         SELECT COUNT(payment_id)
  186. FROM payment
  187. WHERE payment_date BETWEEN ’01-JAN-2003′ AND ’30-JUN-2003′;
  188.         SELECT customer_id, COUNT(payment_id)
  189. FROM payment
  190. WHERE payment_date BETWEEN ’01-JAN-2003′ AND ’30-JUN-2003′;
  191.         SELECT COUNT(payment_id)
  192. FROM payment
  193. WHERE payment_date BETWEEN ’01-JAN-2003′ AND ’30-JUN-2003′
  194. GROUP BY customer_id;
  195. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  196.                 14.     You want to write a report that returns the average salary of all employees in the company, sorted by departments.
  197. The EMPLOYEES table contains the following columns:
  198. EMPLOYEES:
  199. EMP_ID NUMBER(10) PRIMARY KEY
  200. LNAME VARCHAR2(20)
  201. FNAME VARCHAR2(20)
  202. DEPT VARCHAR2(20)
  203. HIRE_DATE DATE
  204. SALARY NUMBER(10)
  205. Which SELECT statement will return the information that you require?
  206.         Mark for Review
  207. (1) Points
  208.         SELECT salary (AVG)
  209. FROM employees
  210. GROUP BY dept;
  211.         SELECT AVG (salary)
  212. FROM employees
  213. GROUP BY dept;
  214. (*)
  215.         SELECT AVG (salary)
  216. FROM employees
  217. BY dept;
  218.         SELECT AVG salary
  219. FROM employees
  220. BY dept;
  221. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  222.                 15.     Evaluate this SELECT statement:
  223. SELECT MAX(salary), department_id
  224. FROM employees
  225. GROUP BY department_id;
  226. Which values are displayed?
  227.         Mark for Review
  228. (1) Points
  229.         The highest salary for all employees.
  230.         The highest salary in each department. (*)
  231.         The employees with the highest salaries.
  232.         The employee with the highest salary for each department.
  233. Correct         Correct
  234.                 16.     Evaluate this statement:
  235. SELECT department_id, AVG(salary)
  236. FROM employees
  237. WHERE job_id <> 69879
  238. GROUP BY job_id, department_id
  239. HAVING AVG(salary) > 35000
  240. ORDER BY department_id;
  241. Which clauses restricts the result? Choose two.
  242.         Mark for Review
  243. (1) Points
  244.                         (Choose all correct answers)
  245.         SELECT department_id, AVG(salary)
  246.         WHERE job_id <> 69879 (*)
  247.         GROUP BY job_id, department_id
  248.         HAVING AVG(salary) > 35000 (*)
  249. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  250.                 17.     The EMPLOYEES table contains these columns:
  251. ID_NUMBER NUMBER Primary Key
  252. NAME VARCHAR2 (30)
  253. DEPARTMENT_ID NUMBER
  254. SALARY NUMBER (7,2)
  255. HIRE_DATE DATE
  256. Evaluate this SQL statement:
  257. SELECT id_number, name, department_id, SUM(salary)
  258. FROM employees
  259. WHERE salary > 25000
  260. GROUP BY department_id, id_number, name
  261. ORDER BY hire_date;
  262. Why will this statement cause an error?
  263.         Mark for Review
  264. (1) Points
  265.         The HAVING clause is missing.
  266.         The WHERE clause contains a syntax error.
  267.         The SALARY column is NOT included in the GROUP BY clause.
  268.         The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
  269. Incorrect               Incorrect. Refer to Section 5 Lesson 1.
  270.                 18.     To control the order of rows returned using SET operators, the ORDER BY clause is used ______ and is placed in the _____ SELECT statement of the query. Mark for Review
  271. (1) Points
  272.         ONCE; FIRST
  273.         TWICE; FIRST
  274.         ONCE; LAST (*)
  275.         IN ALL; LAST
  276. Incorrect               Incorrect. Refer to Section 5 Lesson 3.
  277.                 19.     When using SET operators the number of columns and the data types of the columns must be identical in all of the SELECT statements used in the query. True or False?    Mark for Review
  278. (1) Points
  279.         True (*)
  280.         False
  281. Correct         Correct
  282.         Section 6
  283.                 20.     Evaluate this SQL statement:
  284. SELECT employee_id, last_name, salary
  285. FROM employees
  286. WHERE department_id IN
  287.    (SELECT department_id
  288.    &nbspFROM employees
  289.    &nbspWHERE salary > 30000 AND salary < 50000);
  290. Which values will be displayed?
  291.         Mark for Review
  292. (1) Points
  293.         Only employees who earn more than $30,000.
  294.         Only employees who earn less than $50,000.
  295.         All employees who work in a department with employees who earn more than $30,000 and more than $50,000.
  296.         All employees who work in a department with employees who earn more than $30,000, but less than $50,000. (*)
  297. Incorrect               Incorrect. Refer to Section 6 Lesson 3.
  298. Section 6
  299.                 21.     You are looking for Executive information using a subquery.
  300. What will the following SQL statement display?
  301. SELECT department_id, last_name, job_id
  302. FROM employees
  303. WHERE department_id IN
  304.    (SELECT department_id FROM departments WHERE department_name = ‘Executive’);
  305.         Mark for Review
  306. (1) Points
  307.         The department ID, department name and last name for every employee in the Executive department.
  308.         The department ID, last name, department name for every Executive in the employees table.
  309.         The department ID, last name, job ID from departments for Executive employees.
  310.         The department ID, last name, job ID for every employee in the Executive department. (*)
  311. Incorrect               Incorrect. Refer to Section 6 Lesson 3.
  312.                 22.     Evaluate this SELECT statement:
  313. SELECT player_id, name
  314. FROM players
  315. WHERE team_id IN
  316.    (SELECT team_id
  317.    &nbspFROM teams
  318.    &nbspWHERE team_id > 300 AND salary_cap > 400000);
  319. What would happen if the inner query returned a NULL value?
  320.         Mark for Review
  321. (1) Points
  322.         No rows would be returned by the outer query. (*)
  323.         A syntax error in the outer query would be returned.
  324.         A syntax error in the inner query would be returned.
  325.         All the rows in the PLAYER table would be returned by the outer query.
  326. Correct         Correct
  327.                 23.     Which statement is false?       Mark for Review
  328. (1) Points
  329.         The WITH clause retrieves the results of one or more query blocks.
  330.         The WITH clause decreases performance. (*)
  331.         The WITH clause makes the query simple to read .
  332.         Stores the results for the user who runs the query.
  333. Correct         Correct
  334.                 24.     A correlated subquery is evaluated _____ for each row processed by the parent statement.        Mark for Review
  335. (1) Points
  336.         EVERY TIME
  337.         ONCE (*)
  338.         COMPLETELY
  339. Incorrect               Incorrect. Refer to Section 6 Lesson 4.
  340.                 25.     Oracle allows you to write named subqueries in one single statement, as long as you start your statement with the keyword WITH. True or False?  Mark for Review
  341. (1) Points
  342.         True (*)
  343.         False
  344. Correct         Correct
  345.                 26.     A correlated subquery will _______ a candidate row from an outer query, _______ the inner query using candidate row value, and _______ values from the inner query to qualify or disqualify the candidate row.  Mark for Review
  346. (1) Points
  347.         CREATE; EXECUTE; USE
  348.         DELETE; UPDATE; INSERT
  349.         GET; EXECUTE; USE (*)
  350.         ROLLUP; GRANT; DROP
  351. Incorrect               Incorrect. Refer to Section 6 Lesson 4.
  352.                 27.     Which best describes a single-row subquery?     Mark for Review
  353. (1) Points
  354.         A query that returns only one row from the inner SELECT statement (*)
  355.         A query that returns one or more rows from the inner SELECT statement
  356.         A query that returns only one column value from the inner SELECT statement
  357.         A query that returns one or more column values from the inner SELECT statement
  358. Incorrect               Incorrect. Refer to Section 6 Lesson 2.
  359.                 28.     If a single-row subquery returns a null value and uses the equality comparison operator, what will the outer query return?      Mark for Review
  360. (1) Points
  361.         No rows (*)
  362.         All the rows in the table
  363.         A null value
  364.         An error
  365. Incorrect               Incorrect. Refer to Section 6 Lesson 2.
  366.                 29.     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
  367. (1) Points
  368.         =
  369.         >
  370.         <=
  371.         >= (*)
  372. Correct         Correct
  373.                 30.     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
  374. (1) Points
  375.         SELECT product_name
  376. FROM products
  377. WHERE cost > (SELECT AVG(cost)
  378. FROM product);
  379. (*)
  380.         SELECT product_name
  381. FROM products
  382. WHERE cost > AVG(cost);
  383.         SELECT AVG(cost), product_name
  384. FROM products
  385. WHERE cost > AVG(cost)
  386. GROUP by product_name;
  387.         SELECT product_name
  388. FROM (SELECT AVG(cost) FROM product)
  389. WHERE cost > AVG(cost);
  390. Incorrect               Incorrect. Refer to Section 6 Lesson 1.
  391. Section 6
  392.                 31.     The EMPLOYEES and ORDERS tables contain these columns:
  393. EMPLOYEES
  394. EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY
  395. FIRST_NAME VARCHAR2(30)
  396. LAST_NAME VARCHAR2(30)
  397. ADDRESS VARCHAR2(25)
  398. CITY VARCHAR2(20)
  399. STATE VARCHAR2(2)
  400. ZIP NUMBER(9)
  401. TELEPHONE NUMBER(10)
  402. ORDERS
  403. ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
  404. EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
  405. ORDER_DATE DATE
  406. TOTAL NUMBER(10)
  407. Which SELECT statement will return all orders generated by a sales representative named Franklin during the year 2001?
  408.         Mark for Review
  409. (1) Points
  410.         SELECT order_id, total
  411. FROM ORDERS (SELECT employee_id
  412. FROM employees
  413. WHERE last_name = ‘Franklin’)
  414. WHERE order_date BETWEEN ’01-jan-01′ AND ’31-dec-01′;
  415.         SELECT (SELECT employee_id FROM employees WHERE last_name = ‘Franklin’) AND order_id, total
  416. FROM ORDERS
  417. WHERE order_date BETWEEN ’01-jan-01′ AND ’31-dec-01′;
  418.         SELECT order_id, employee_id, total
  419. FROM ORDERS
  420. WHERE order_date BETWEEN ’01-jan-01′ AND ’31-dec-01′ AND emp_id = ‘Franklin’;
  421.         SELECT order_id, total
  422. FROM ORDERS
  423. WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name = ‘Franklin’)
  424. AND order_date BETWEEN ’01-jan-01′ AND ’31-dec-01′;
  425. (*)
  426. Incorrect               Incorrect. Refer to Section 6 Lesson 1.
  427.                 32.     Which operator can be used with subqueries that return only one row?    Mark for Review
  428. (1) Points
  429.         LIKE (*)
  430.         ANY
  431.         ALL
  432.         IN
  433. Incorrect               Incorrect. Refer to Section 6 Lesson 1.
  434.                 33.     If you use the equality operator (=) with a subquery, how many values can the subquery return?  Mark for Review
  435. (1) Points
  436.         Only 1 (*)
  437.         Up to 2
  438.         Up to 5
  439.         Unlimited
  440. Incorrect               Incorrect. Refer to Section 6 Lesson 1.
  441.                 34.     Which operator can be used with a multiple-row subquery?        Mark for Review
  442. (1) Points
  443.         IN (*)
  444.         <>
  445.         =
  446.         LIKE
  447. Incorrect               Incorrect. Refer to Section 6 Lesson 1.
  448.                 35.     Which of the following is TRUE regarding the order of subquery execution?       Mark for Review
  449. (1) Points
  450.         The outer query is executed first
  451.         The subquery executes once after the main query
  452.         The subquery executes once before the main query (*)
  453.         The result of the main query is used with the subquery
  454. Incorrect               Incorrect. Refer to Section 6 Lesson 1.
  455.                 36.     Using a subquery in which clause will return a syntax error?    Mark for Review
  456. (1) Points
  457.         WHERE
  458.         FROM
  459.         HAVING
  460.         You can use subqueries in all of the above clauses. (*)
  461. Incorrect               Incorrect. Refer to Section 6 Lesson 1.
  462.         Section 7
  463.                 37.     The PRODUCTS table contains these columns:
  464. PRODUCT_ID NUMBER NOT NULL
  465. PRODUCT_NAME VARCHAR2 (25)
  466. SUPPLIER_ID NUMBER NOT NULL
  467. LIST_PRICE NUMBER (7,2)
  468. COST NUMBER (5,2)
  469. QTY_IN_STOCK NUMBER(4)
  470. LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
  471. Which INSERT statement will execute successfully?
  472.         Mark for Review
  473. (1) Points
  474.         INSERT INTO products
  475. VALUES (2958, ‘Cable’, 8690, 7.09, 4.04, 700);
  476. (*)
  477.         INSERT INTO products
  478. VALUES (2958, ‘Cable’, 8690, 7.09, 4.04, SYSDATE);
  479.         INSERT INTO products(product_id, product_name)
  480. VALUES (2958, ‘Cable’);
  481.         INSERT INTO products(product_id, product_name, supplier_id
  482. VALUES (2958, ‘Cable’, 8690, SYSDATE);
  483. Correct         Correct
  484.                 38.     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
  485. (1) Points
  486.         An ON clause
  487.         A SET clause
  488.         A subquery (*)
  489.         A function
  490. Incorrect               Incorrect. Refer to Section 7 Lesson 1.
  491.                 39.     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
  492. (1) Points
  493.         Use the NULL keyword.
  494.         Use the ON clause
  495.         Omit the column in the column list. (*)
  496.         It is not possible to implicitly insert a null value in a column.
  497. Incorrect               Incorrect. Refer to Section 7 Lesson 1.
  498.                 40.     The PRODUCTS table contains these columns:
  499. PROD_ID NUMBER(4)
  500. PROD_NAME VARCHAR2(25)
  501. PROD_PRICE NUMBER(3)
  502. You want to add the following row data to the PRODUCTS table:
  503. (1) a NULL value in the PROD_ID column
  504. (2) “6-foot nylon leash” in the PROD_NAME column
  505. (3) “10” in the PROD_PRICE column
  506. You issue this statement:
  507. INSERT INTO products
  508. VALUES (null,’6-foot nylon leash’, 10);
  509. What row data did you add to the table?
  510.         Mark for Review
  511. (1) Points
  512.         The row was created with the correct data in all three columns. (*)
  513.         The row was created with the correct data in two of three columns.
  514.         The row was created with the correct data in one of the three columns.
  515.         The row was created completely wrong. No data ended up in the correct columns.
  516. Correct         Correct
  517.         Section 7
  518.                 41.     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
  519. (1) Points
  520.         The USING clause
  521.         The ON clause
  522.         The WHERE clause
  523.         The SET clause (*)
  524. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  525.                 42.     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:
  526. EMPLOYEE_ID NUMBER(10) PRIMARY KEY
  527. LAST_NAME VARCHAR2(20)
  528. FIRST_NAME VARCHAR2(20)
  529. DEPARTMENT_ID VARCHAR2 (20)
  530. HIRE_DATE DATE
  531. SALARY NUMBER(10)
  532. Which UPDATE statement will accomplish your objective?
  533.         Mark for Review
  534. (1) Points
  535.         UPDATE employees
  536. SET last_name = ‘cooper’
  537. WHERE last_name = ‘roper’;
  538. (*)
  539.         UPDATE employees last_name = ‘cooper’
  540. WHERE last_name = ‘roper’;
  541.         UPDATE employees
  542. SET last_name = ‘roper’
  543. WHERE last_name = ‘cooper’;
  544.         UPDATE employees
  545. SET cooper = ‘last_name’
  546. WHERE last_name = ‘roper’;
  547. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  548.                 43.     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
  549. (1) Points
  550.         INSERT INTO my_employees SET last_name = ‘Rockefeller’ WHERE employee_ID = 189;
  551.         INSERT my_employees SET last_name = ‘Rockefeller’ WHERE employee_ID = 189;
  552.         UPDATE INTO my_employees SET last_name = ‘Rockefeller’ WHERE employee_ID = 189;
  553.         UPDATE my_employees SET last_name = ‘Rockefeller’ WHERE employee_ID = 189; (*)
  554. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  555.                 44.     You need to update the area code of employees that live in Atlanta. Evaluate this partial UPDATE statement:
  556. UPDATE employee
  557. SET area_code = 770
  558. Which of the following should you include in your UPDATE statement to achieve the desired results?
  559.         Mark for Review
  560. (1) Points
  561.         UPDATE city = Atlanta;
  562.         SET city = ‘Atlanta’;
  563.         WHERE city = ‘Atlanta’; (*)
  564.         LIKE ‘At%’;
  565. Correct         Correct
  566.                 45.     You need to remove a row from the EMPLOYEES table. Which statement would you use?       Mark for Review
  567. (1) Points
  568.         UPDATE with a WHERE clause
  569.         INSERT with a WHERE clause
  570.         DELETE with a WHERE clause (*)
  571.         MERGE with a WHERE clause
  572. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  573.                 46.     What keyword in an UPDATE statement speficies the columns you want to change?   Mark for Review
  574. (1) Points
  575.         SELECT
  576.         WHERE
  577.         SET (*)
  578.         HAVING
  579. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  580.                 47.     What would happen if you issued a DELETE statement without a WHERE clause?      Mark for Review
  581. (1) Points
  582.         All the rows in the table would be deleted. (*)
  583.         An error message would be returned.
  584.         No rows would be deleted.
  585.         Only one row would be deleted.
  586. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  587.                 48.     The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
  588. TEACHERS
  589. TEACHER_ID NUMBER(5)
  590. NAME VARCHAR2(25)
  591. SUBJECT_ID NUMBER(5)
  592. HIRE_DATE DATE
  593. SALARY NUMBER(9,2)
  594. CLASS_ASSIGNMENTS
  595. CLASS_ID NUMBER(5)
  596. TEACHER_ID NUMBER(5)
  597. START_DATE DATE
  598. MAX_CAPACITY NUMBER(3)
  599. Which scenario would require a subquery to return the desired results?
  600.         Mark for Review
  601. (1) Points
  602.         You need to display the start date for each class taught by a given teacher.
  603.         You need to create a report to display the teachers who were hired more than five years ago.
  604.         You need to display the names of the teachers who teach classes that start within the next week.
  605.         You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. (*)
  606. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  607.                 49.     When the WHERE clause is missing in a DELETE statement, what is the result?     Mark for Review
  608. (1) Points
  609.         All rows are deleted from the table. (*)
  610.         The table is removed from the database.
  611.         An error message is displayed indicating incorrect syntax.
  612.         Nothing. The statement will not execute.
  613. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
  614.                 50.     Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
  615. PLAYERS
  616. PLAYER_ID NUMBER Primary Key
  617. LAST_NAME VARCHAR2 (30)
  618. FIRST_NAME VARCHAR2 (25)
  619. TEAM_ID NUMBER
  620. MGR_ID NUMBER
  621. SIGNING_BONUS NUMBER(9,2)
  622. SALARY NUMBER(9,2)
  623. MANAGERS
  624. MANAGER_ID NUMBER Primary Key
  625. LAST_NAME VARCHAR2 (20)
  626. FIRST_NAME VARCHAR2 (20)
  627. TEAM_ID NUMBER
  628. TEAMS
  629. TEAM_ID NUMBER Primary Key
  630. TEAM_NAME VARCHAR2 (20)
  631. OWNER_LAST_NAME VARCHAR2 (20)
  632. OWNER_FIRST_NAME VARCHAR2 (20)
  633. Which situation would require a subquery to return the desired result?
  634.         Mark for Review
  635. (1) Points
  636.         To display the names each player on the Lions team
  637.         To display the maximum and minimum player salary for each team
  638.         To display the names of the managers for all the teams owned by a given owner (*)
  639.         To display each player, their manager, and their team name for all teams with a id value greater than 5000
  640. Incorrect               Incorrect. Refer to Section 7 Lesson 2.
Advertisements