Oracle Mid Exam Totpart1

March 26, 2018 | Author: Kyuuketsuki Kame | Category: Sql, Table (Database), Data, Data Management, Databases


Comments



Description

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. (*) 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 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; 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; 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 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, leftpadded 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 (*) 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 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 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 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 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 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: 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; 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) 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; (*) 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 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" 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 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 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? 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; 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; 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. 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); 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 = 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 (*) 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 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 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'; 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: 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 (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 e. SELECT e. Which query will retrieve all the rows in the EMPLOYEES table. e.department_id. (*) SELECT e.department_id = d. .department_id = d.department_name FROM employees e JOIN departments d USING (e. e.department_id.department_id).department_name FROM employees e NATURAL JOIN departments d.department_name FROM employees e LEFT OUTER JOIN departments d ON (e. d.last_name.last_name. d.last_name.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e. e. d.41.department_id.department_id). d.department_id).department_id. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e.department_id = d. SELECT e.last_name. Refer to Section 4 42.Incorrect. 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 . Refer to Section 4 43. 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. 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.full outer joins (*) right outer joins Incorrect. dept_id FROM employee GROUP BY dept_id. . Refer to Section 5 45. Evaluate this SELECT statement: SELECT MAX(salary). Refer to Section 4 44. Which values are displayed? Mark for Review (1) Points The highest salary for all employees. . Refer to Section 5 46. The highest salary in each department. (*) Group functions can only be used in a SELECT list. Group functions can be used in a WHERE clause. Incorrect. (*) The employees with the highest salaries. The employee with the highest salary for each department. Which statement about group functions is true? Mark for Review (1) Points Group functions ignore null values. A query that includes a group function in the SELECT list must include a GROUP BY clause. What is the best explanation as to why this SQL statement will NOT execute? SELECT department_id "Department". Refer to Section 5 48. AVG (salary)"Average" FROM employees GROUP BY Department. SUM. Incorrect. Incorrect. VARIANCE. The AVG. The department id is not listed in the departments table. and STDDEV functions can be used with which of the following? Mark for Review (1) Points . (*) The GROUP BY clause must have something to GROUP. You cannot use a column alias in the GROUP BY clause. Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. Refer to Section 5 47. Only numeric data types (*) Integers only Any data type All except numeric Correct 49. Which SELECT statement should you use? Mark for Review (1) Points SELECT AVG(payment_amount) FROM payment .00 89453485 8549038 15-FEB-03 INTEREST 596.00 You need to determine the average payment amount made by each customer in January.00 85490345 5489304 20-MAR-03 BASIC 568. February and March of 2003. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859. Which group function will you use? Mark for Review (1) Points STDEV . SELECT SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'. MAR).WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003'. Correct 50. SELECT AVG(payment_amount) FROM payment WHERE TO_CHAR(payment_date) IN (JAN. You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. (*) SELECT AVG(payment_amount) FROM payment. FEB. 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) .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. SELECT SUM(order_dt) SELECT SUM(order_amount) (*) WHERE MAX(order_dt) = order_dt SELECT location_id. Refer to Section 5 . Refer to Section 5 52. MIN(AVG(order_amount)) (*) Incorrect. 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. Which group function will you use? Mark for Review (1) Points AVG (*) MEAN MEDIAN AVERAGE Correct 54. number and date data types? (Choose more than one answer) Mark for Review (1) Points (Choose all correct answers) SUM MAX (*) MIN (*) . Which group functions below act on character.53. You need to calculate the average salary of employees in each department. 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. What happens when this statement is issued? Mark for Review (1) Points .AVG COUNT (*) Correct 55. prod_qty) FROM products. 00 758960 SANDAL 86979 You issue this SELECT statement: SELECT COUNT(category) .00 869506 SANDAL 89690 15. An error occurs. (*) Incorrect.Both the average price and the average quantity of the products are returned. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. Refer to Section 5 56.00 890890 LOAFER 89789 14. Only the average quantity of the products is returned.00 968950 SANDAL 85909 10. The values in the PROD_PRICE column and the PROD_QTY column are averaged together.00 809090 LOAFER 89098 10.00 857689 HEEL 85940 11. 99 0. Refer to Section 5 57.10 768385 862459 849869 5. Which value is displayed? Mark for Review (1) Points 0 6 7 (*) The statement will NOT execute successfully.25 0. Incorrect.FROM styles.50 .15 543949 349302 453235 4.60 954039 439203 438925 5.05 867950 985490 945809 5. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT 890898 847589 848399 8.60 0. Which SQL statement did you execute? Mark for Review (1) Points SELECT COUNT(discount) FROM line_item. Incorrect. SELECT AVG(discount) FROM line_item. Refer to Section 5 58. SELECT COUNT(*) FROM line_item. Group functions can avoid computations involving duplicate values by including which keyword? Mark for Review (1) Points NULL DISTINCT (*) SELECT .You query the LINE_ITEM table and a value of 5 is returned. (*) SELECT SUM(discount) FROM line_item. Refer to Section 5 . (*) The number of unique PRODUCT_IDs in the table is displayed. Incorrect. Refer to Section 5 59. An error occurs because no WHERE clause is included in the SELECT statement. An error occurs due to an error in the SELECT clause. Which statement is true? Mark for Review (1) Points The number of rows in the table is displayed. Evaluate this SELECT statement: SELECT COUNT(*) FROM products.UNLIKE Incorrect. The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8. Refer to Section 6 .60. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Incorrect.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. COUNT(type) FROM manufacturer GROUP BY location_id. (*) SELECT location_id. Which SELECT statement should you use? Mark for Review (1) Points SELECT location_id.61. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. SELECT location_id. COUNT(DISTINCT type) FROM manufacturer. . 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. SELECT location_id. 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 . Correct 62. COUNT(DISTINCT type) FROM manufacturer GROUP BY type. 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) . MIN (prod_price) FROM products GROUP BY prod_price. (*) SELECT MIN (prod_price).PROD_CAT VARCHAR2(15) PROD_PRICE NUMBER(5) PROD_QTY NUMBER(4) You need to identify the minimum product price in each product category. MIN (prod_price) FROM products GROUP BY prod_cat. SELECT prod_cat. prod_cat FROM products GROUP BY MIN (prod_price). Which statement could you use to accomplish this task? Mark for Review (1) Points SELECT prod_cat. . prod_cat. name. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. department_id. Correct 64. MIN (prod_cat) FROM products GROUP BY prod_cat.SELECT prod_price. id_number. The EMPLOYEES table contains these columns: ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER SALARY NUMBER (7. Why will this statement cause an error? Mark for Review . name ORDER BY hire_date.2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. Evaluate this SELECT statement: SELECT SUM(salary). dept_id. The HIRE_DATE column is NOT included in the GROUP BY clause. Which clause of the SELECT statement contains a syntax error? Mark for Review (1) Points SELECT . The WHERE clause contains a syntax error. (*) Correct 65. The SALARY column is NOT included in the GROUP BY clause.(1) Points The HAVING clause is missing. department_name FROM employee WHERE dept_id = 1 GROUP BY department. FROM WHERE GROUP BY (*) Incorrect. Refer to Section 66. The PLAYERS and TEAMS tables contain these columns: PLAYERS PLAYER_ID NUMBER NOT NULL. Which SELECT statement will produce the desired result? Mark for Review (1) Points . 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. team_name. SELECT t.team_name.position) = 'PITCHER' GROUP BY t.position) = 'PITCHER' GROUP BY t. SELECT t.team_name.team_name HAVING COUNT(p.player_id) FROM players p JOIN teams t ON (p.team_id) WHERE UPPER(p.SELECT t.team_id) WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.team_id = t.team_name.player_id) > 5.position) = 'PITCHER' GROUP BY t.team_id = t. teams t ON (p. (*) . COUNT(p.player_id) FROM players p.player_id) > 5.team_id = t. COUNT(p.player_id) FROM players p. teams t ON (p.player_id) FROM players JOIN teams t ON (p. SELECT t. COUNT(p.team_id) WHERE UPPER(p.team_id = t. COUNT(p.player_id) > 5.team_id) WHERE UPPER(p.team_name.team_name HAVING COUNT(p. (*) You can use a column alias in a GROUP BY clause. Refer to Section 6 68. you use should a WHERE clause. Refer to Section 6 67. You must use the HAVING clause with the GROUP BY clause. Using a subquery in which clause will return a syntax error? Mark for Review (1) Points WHERE FROM HAVING .Incorrect. 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. By default. Incorrect. rows are not sorted when a GROUP BY clause is used. There are no places you cannot place subqueries. (*) Incorrect. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns: TEACHERS TEACHER_ID NUMBER(5) Primary Key NAME VARCHAR2 (25) SUBJECT_ID NUMBER(5) . 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. Which two SQL statements correctly use subqueries? (Choose two.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.) 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). (*) . Incorrect. The EMPLOYEES and ORDERS tables contain these columns: EMPLOYEES EMP_ID NUMBER(10) NOT NULL PRIMARY KEY FNAME VARCHAR2(30) LNAME VARCHAR2(30) . SELECT * FROM teachers WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0).SELECT * FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0). Refer to Section 6 71. SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id). total FROM ORDERS (SELECT emp_id FROM employees WHERE lname = 'Franklin') WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01'.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 WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01'. SELECT (SELECT emp_id FROM employees WHERE lname = 'Franklin') AND order_id. the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8. emp_id. total FROM ORDERS WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin'. (*) Correct 72. SELECT order_id.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'.2) OPEN_DATE DATE ORDER_HISTORY . However. You need to display all the orders that were placed on a certain date.ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. you are not sure which supervisor ID belongs to Brad Carter. You need to display each date that a customer placed an order. You need to display all the orders that were placed on the same day as order number 25950.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. (*) Incorrect. Refer to Section 6 73. Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT * . You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id FROM supervisors WHERE last_name = 'Carter').FROM employees WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). SELECT * FROM employees . SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). If a single-row subquery returns a null value and uses the equality comparison operator. (*) Incorrect.WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter'). 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 . Refer to Section 6 74. 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 .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. (*) Incorrect. All of the above. Refer to Section 6 .Incorrect. 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). Refer to Section 6 77. 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). No rows would be returned by the outer query. (*) All the rows in the table would be selected.00). What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. 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 . Incorrect.78. name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. Evaluate this SELECT statement: SELECT customer_id. Only the rows with CUSTOMER_ID values equal to null would be selected. and ALL (*) LIKE BETWEEN. 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 ..(1) Points IN... ANY. =.AND. Refer to Section 6 80. <. and > Incorrect.. 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. Refer 82.Correct 81. All the rows will be selected. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review (1) Points ALL ANY = (*) > Incorrect. . (*) No rows will be selected. Refer to Section 6 83. but less than $50.000. All employees who work in a department with employees who earn more than $30.The data returned may or may not be correct. (*) .000. 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.000 and more than $50.000. Incorrect. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). last_name. All employees who work in a department with employees who earn more than $30. Evaluate this SQL statement: SELECT employee_id. payment_type FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003').Correct 84.00 85490345 5489304 20-MAR-03 BASIC 568.00 89453485 8549038 15-FEB-03 INTEREST 596. Which change could correct the problem? Mark for Review (1) Points Change the outer query WHERE clause to 'WHERE payment_id IN'.00 This statement fails when executed: SELECT customer_id. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859. (*) . Remove the parentheses surrounding the nested SELECT statement. Subquery returns more than one row and single row comparison operator is used. Change the comparison operator to a single-row operator. What is wrong with the following query? SELECT employee_id.Remove the quotes surrounding the date value in the OR clause. Mark for Review (1) Points Single rows contain multiple values and a logical operator is used. (*) Subquery references the wrong table in the WHERE clause. Refer to Section 6 85. . last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). Incorrect. 00 89453485 8549038 15-FEB-03 INTEREST 596. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859. Refer to Section 6 86. customer_id. Incorrect.00 85490345 5489304 20-MAR-03 BASIC 568. it will run without problems.Nothing. Which change could correct the problem? Mark for Review (1) Points . payment_amount FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00).00 This statement fails when executed: SELECT payment_date. (*) Include the PAYMENT_ID column in the select list of the outer query. 1700). Assume all the column names are correct. Refer to Section 6 87. manager_id. 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 (*) . Incorrect.Remove the subquery WHERE clause. The following SQL statement will execute which of the following? INSERT INTO departments (department_id. 'Public Relations'. Remove the single quotes around the date value in the inner query WHERE clause. Change the outer query WHERE clause to 'WHERE payment_id IN'. 100. location_id) VALUES (70. department_name. You need to add a row to an existing table. Refer 89.'Public Relations' will be inserted into the manager_name column Incorrect. Which DML statement should you use? Mark for Review (1) Points UPDATE INSERT (*) DELETE CREATE Incorrect.2) . Refer to Section 7 88.2) COST NUMBER (5. The PRODUCTS table contains these columns: PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. (*) INSERT INTO products VALUES (2958.09.04. INSERT INTO products(product_id.09. What could you use in the INSERT statement to accomplish this task? Mark for Review (1) Points an ON clause a SET clause . 'Cable'. SYSDATE). Incorrect. 'Cable'). 4. Refer to Section 7 90. INSERT INTO products(product_id. 8690. 'Cable'.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. 7. 7. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. 'Cable'. product_name) VALUES (2958. 8690. supplier_id VALUES (2958. 700). SYSDATE). 4. product_name.04. 8690. Janet is the only person with the last name of Roper that is employed by the company. has informed you that she was recently married. and she has requested that you update her name in the employee database. One of the sales representatives. . Her new last name is Cooper. 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'. Janet Roper.a subquery (*) a function Correct 91. Which statement would you use? Mark for Review (1) Points UPDATE with a WHERE clause . UPDATE employees SET cooper = 'lname' WHERE lname = 'roper'. You need to remove a row from the EMPLOYEE table. Incorrect. UPDATE employees SET lname = 'roper' WHERE lname = 'cooper'. Refer to Section 7 92.(*) UPDATE employees lname = 'cooper' WHERE lname = 'roper'. Examine the structures of the PLAYERS. MANAGERS.2) SALARY NUMBER(9.2) MANAGERS MANAGER_ID NUMBER Primary Key LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) TEAM_ID NUMBER .INSERT with a WHERE clause DELETE with a WHERE clause (*) MERGE with a WHERE clause Correct 93. 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. and their team name for all teams with a id value greater than 5000 Correct 94. their manager.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. The EMPLOYEES table contains the following columns: EMP_ID NUMBER(10) PRIMARY KEY LNAME VARCHAR2(20) FNAME VARCHAR2(20) . Currently. 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. (*) . all employees in department 10 have the same salary value.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.DEPT VARCHAR2(20) HIRE_DATE DATE SALARY NUMBER(9.2) BONUS NUMBER(9. Which statement should you execute? Mark for Review (1) Points UPDATE employee SET salary = SELECT salary FROM employee WHERE emp_id = 89898. Incorrect. Incorrect. Evaluate this statement: DELETE FROM customer. The statement deletes the first row in the CUSTOMERS table. Which statement is true? Mark for Review (1) Points The statement deletes all the rows from the CUSTOMER table. Refer to Section 7 96. The statement removes the structure of the CUSTOMER table from the database. When the WHERE clause is missing in a DELETE statement. (*) The statement deletes the CUSTOMER column. what is the result? Mark for Review (1) Points . Refer to Section 7 95.UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10). 125.All rows are deleted from the table.2) You need to increase the salary of each player for all players on the Tiger team by 12.5 percent. (*) The table is removed from the database. 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. 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. The statement will not execute. An error message is displayed indicating incorrect syntax. Nothing. 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. whose unique employee identification number is 348.UPDATE players SET salary = salary * . DELETE * FROM employees WHERE id_num = 348.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. UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960. (*) DELETE FROM employees WHERE lname = jones. Which clause should you include in the UPDATE statement to update multiple columns? Mark for Review (1) Points the USING clause . 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.DELETE 'jones' FROM employees. You need to update the expiration date of products manufactured before June 30th . Correct 99. beginning with the first character up to the fifth character. 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.the ON clause the WHERE clause the SET clause (*) Correct 1. You need to return a portion of each employee's last name. Which character function should you use? (1) Points INSTR Mark for Review TRUNC . Evaluate this SELECT statement: SELECT LENGTH(email) FROM employee. 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. What will this SELECT statement display? Mark for Review (1) Points The longest e-mail address in the EMPLOYEE table. .SUBSTR (*) CONCAT 3. The email address of each employee in the EMPLOYEE table. and date column values? Mark for Review (1) Points CONCAT. Which functions can be used to manipulate character. You need to display the number of characters in each customer's last name. LOWER. number.4. and INITCAP . RPAD. Which function should you use? Mark for Review (1) Points LENGTH (*) LPAD COUNT SUBSTR 5. and TRIM (*) UPPER. LOWER (*) . In which order are the functions evaluated? Mark for Review (1) Points LOWER. first_name)). SUBSTR. and MOD ROUND. SUBSTR SUBSTR. CONCAT LOWER. 1. CONCAT. 5) "ID" FROM employee. LOWER CONCAT. TRUNC. and ADD_MONTH 6. SUBSTR. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. TRUNC.ROUND. CONCAT. IN. not on numbers. . (*) The ROUND number function rounds a value to a specified decimal place or the nearest whole number.. Which three statements about functions are true? (Choose three.. Which comparison operator retrieves a list of values? (1) Points Mark for Review IN (*) LIKE BETWEEN.7. (*) The CONCAT function can only be used on character strings..) Mark for Review (1) Points (Choose all correct answers) The SYSDATE function returns the Oracle Server date and time.. 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 . (*) 10.IS NULL The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length. Which element would you use? Mark for Review (1) Points . Evaluate this SELECT statement: SELECT SYSDATE + 30 FROM dual. 12.CONCAT 11. 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. You need to display the current year as a character value (for example: Two Thousand and One). 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 .RR YY YYYY YEAR (*) 13. (SYSDATE-hire_date)/7 AS WEEKS FROM employees WHERE department_id = 90. # of WEEKS FROM employees WHERE department_id = 90. . (*) SELECT last name. 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. SELECT last_name. (SYSDATE-hire_date)/7 DISPLAY WEEKS FROM employees WHERE department id = 90.MONTHS_BETWEEN (*) 14. (*) Single row functions return one or more results per row. (SYSDATE-hire_date)AS WEEK FROM employees WHERE department_id = 90. 16. 17.SELECT last_name. Single row functions can be nested. (1) Points Which statement concerning single row functions is true? Mark for Review Single row functions can accept only one argument.) Mark for Review (1) Points (Choose all correct answers) . Single row functions cannot modify a data type. Which two statements concerning SQL functions are true? (Choose two. but can return multiple values. (*) Number functions can return number or character values. Not all date functions return date values. . Conversion functions convert a value from one data type to another data type. Which three statements concerning explicit data type conversions are true? (Choose three. (*) Single-row functions manipulate groups of rows to return one result per group of rows. 18.Character functions can accept numeric input.) 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_CHAR function to convert a number or date value to character string.Use the TO_DATE function to convert a character string to a date value. (*) 19. 2000 Which SELECT statement could you use? Mark for Review (1) Points . (*) Use the TO_DATE function to convert a date value to character string or number. (*) Use the TO_NUMBER function to convert a character string of digits to a number. 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. SELECT TO_CHAR(hire_date. Month DD. (*) SELECT hire_date(TO_CHAR 'Month DD'. YYYY) FROM employees. YYYY') FROM employees.TO_DATE('01-OCT-2004') (*) . ' YYYY') FROM employees. ' YYYY') FROM employees. 20. 'Month DD'. Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . SELECT TO_CHAR(hire_date. 'Month DD. SELECT TO_CHAR(hire_date. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 . If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001.6 SYSDATE + 30 / 24 21.NEXT_DAY(hire_date) + 5 SYSDATE . A value of 0 would be displayed. . 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.Incorrect Incorrect. (*) A value of 10 would be displayed. '0') FROM PRODUCT. Refer to Section 2 Previous 22. Page 21 of 100 Next Summary The PRODUCT table contains this column: PRICE NUMBER(7.2) Evaluate this statement: SELECT NVL(10 / price. You need to replace null values in the DEPT_ID column with the text "N/A". 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. 23.The statement would fail because values cannot be divided by null. Which functions should you use? Mark for Review (1) Points TO_CHAR and NVL (*) TO_CHAR and NULL . Incorrect. exhausting all possibilities The table is joined to another equal table All rows that do not match in the WHERE clause are displayed Incorrect 26. 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. Refer to Section 3 The PATIENTS and DOCTORS tables contain these columns: PATIENTS PATIENT_ID NUMBER(9) . one column to the next column.TO_CHAR and NULLIF 25. doctor_id FROM patients. doctors.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. 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 . how many join conditions are needed in the WHERE clause? Mark for Review (1) Points 0 1 2 (*) 3 Incorrect Incorrect. The company president would like the sales listed starting with the highest amount first.A syntax error 27. 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. When joining 3 tables in a SELECT statement. Refer to Section 3 28. The EMPLOYEES table and the SALES_DEPT table contain the following columns: . s. s. sales_dept s ORDER BY sales DESC . s.emp_id.bonus.emp_id.sales FROM employees e. e.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. e.fname.lname. s. You need to create a report that lists all employees in the Sales department who do not earn $25.bonus.emp_id = s.fname.bonus IS NOT NULL AND sales > 50000.emp_id.emp_id.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC.emp_id.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC. sales_dept s WHERE e.emp_id. s.WHERE e. sales ORDER BY sales DESC FROM employees e.000 per year.bonus.emp_id AND s. sales_dept s WHERE e. (*) 29.emp_id = s. SELECT e.emp_id = s.lname.emp_id AND s.lname.bonus. SELECT e. e. s. s. sales WHERE e. e. sales_dept s AND s. s.emp_id. s. s. e. e. e. s.emp_id = s.emp_id AND sales > 50000 AND s. s. sales FROM employees e.bonus IS NOT NULL.fname. SELECT e.fname. Which query should you issue to accomplish this task? Mark for Review . e.emp_id.emp_id FROM employees e.lname. (1) Points SELECT last_name. first_name. salary FROM employees WHERE salary != 25000 AND dept_id = 10. SELECT last_name. salary FROM employees WHERE salary <= 25000 AND dept_id = 10. SELECT last_name. . salary FROM employees WHERE salary > 25000 AND dept_id = 10. first_name. SELECT last_name. first_name. salary FROM employees WHERE salary = 25000 AND dept_id = 10. first_name. company. 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.total_sales FROM customers c. s. sales s WHERE c.cust_id (+).cust_id = s. c. .(*) 30.cust_id. company.cust_id. 31. total_sales FROM customers. total_sales FROM customers c. company.cust_id. company.cust_id = s. (*) SELECT cust_id. sales s WHERE c.total_sales FROM customers c.cust_id = s.cust_id. s. 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 .SELECT cust_id. sales s WHERE c. The EMPLOYEE_ID column in the EMPLOYEE table corresponds to the EMPLOYEE_ID column of the ORDER table. SELECT c. c. sales WHERE cust_id = cust_id. The FULL. 33. for Review (1) Points Which of the following best describes the function of an outer join? Mark . RIGHT. (*) Outer joins are always evaluated before other types of joins in the query. or LEFT keyword must be included.self-join outer join (*) equijoin 32. Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. The OR operator cannot be used to link outer join conditions. Which of the following conditions will cause an error on a NATURAL JOIN? Review (1) Points Mark for When you attempt to write it as an equijoin. (*) 34. . When the NATURAL JOIN clause is based on all columns in the two tables that have the same name. 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 only those rows that do not meet the join criteria. An outer join will return data only if both tables contain an identical pair of columns. If it selects rows from the two tables that have equal values in all matched 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. Which type of join would you create to join the tables on both of the columns? Mark for Review (1) Points . You need to join two tables that have two columns with the same name and compatible data types. (*) 35. then an error is returned. 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.If the columns having the same names have different data types. Natural join (*) Cross join Outer join Self-join 37. for Review (1) Points Which of the following statements is the simplest description of a nonequijoin? Mark 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.patient_id = c. (*) JOIN admission c . Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b. Evaluate this SELECT statement: SELECT a.physician_id).fname as "Physician". ' || b.physician_id).A join that joins a table to itself 38.physician_id = c. JOIN admission c ON (a.admission FROM patient a JOIN physician b ON (b.fname as "Patient".patient_id).lname || '. b.physician_id = c.lname || '. c. (*) . 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.patient_id) 39.ON (a. (1) Points The primary advantage of using JOIN ON is: Mark for Review 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.patient_id = c. department_id. The CUSTOMER and ORDER tables have a corresponding column. The CUSTOMER and ORDER tables have no columns with identical names.department_id). d.department_name FROM employees e NATURAL JOIN departments d. CUST_ID. Which query will retrieve all the rows in the EMPLOYEES table.last_name. 41. .last_name.department_id. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e. The CUST_ID column in the ORDER table contains null values that need to be displayed. e. d.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e.The ORDER table contains a column that has a referential constraint to a column in the PRODUCT table. e. SELECT e.department_id = d. (*) SELECT e.department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_name FROM employees e JOIN departments d USING (e.department_id = d.department_id).department_id = d.last_name.last_name. d. 42.department_id). e.department_id.SELECT e. 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 (*) . e.department_id. d. required? (1) Points If a select list contains both a column as well as a group function then what clause is Mark for Review having clause join clause .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. order by clause group by clause (*) 45. . dept_id FROM employee GROUP BY dept_id. Evaluate this SELECT statement: SELECT MIN(hire_date). Which values are displayed? Mark for Review (1) Points The earliest hire date in each department. The latest hire date in the EMPLOYEE table. (*) The the earliest hire date in the EMPLOYEE table. Group functions can be used in a WHERE clause. 47. (*) Group functions can only be used in a SELECT list.The hire dates in the EMPLOYEE table that contain NULL values 46. A query that includes a group function in the SELECT list must include a GROUP BY clause. (1) Points Which statement about group functions is true? Mark for Review Group functions ignore null values. Group functions can be nested to a depth of? Mark for Review (1) Points . 48.three four two (*) Group functions cannot be nested. 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 . 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 . The VENDORS table contains these columns: VENDOR_ID NUMBER Primary Key NAME VARCHAR2(30) LOCATION_ID NUMBER ORDER_DT DATE ORDER_AMOUNT NUMBER(8.49. Mark for Review (1) Points . Group functions return a value for ________________ and ________________ null values in their computations.SELECT location_id. MIN(AVG(order_amount)) (*) Incorrect Incorrect. Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE 51. You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. Refer to Section 5 50. a row set. 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 . include 52. ignore (*) each row. ignore a row set. include each row. 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) .AVERAGE 53. The AVG. 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. VARIANCE. SUM. The values in the PROD_PRICE column and the PROD_QTY column are averaged together. Only the average quantity of the products is returned. (*) 55. prod_qty) FROM products. An error occurs. 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.The following statement is issued: SELECT AVG(prod_price. The EMPLOYEES table contains these columns: . LAST_NAME.EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(9.) Mark for Review (1) Points (Choose all correct answers) MAX (*) SUM AVG MIN (*) .2) Which three functions could be used with the HIRE_DATE.2) COMM_PCT NUMBER(4.2) HIRE_DATE DATE BONUS NUMBER(7. or SALARY columns? (Choose three. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID 890898 847589 848399 8.COUNT (*) 56.60 867950 985490 945809 5.10 0.60 PRODUCT_ID 0.05 PRICE DISCOUNT .99 768385 862459 849869 5. SELECT COUNT (*) FROM products. SELECT COUNT FROM products. Which SELECT statement will calculate the number of rows in the PRODUCTS table? for Review (1) Points Mark SELECT COUNT(products). (*) SELECT ROWCOUNT FROM products 57. 50 0. SELECT AVG(discount) FROM line_it 58.954039 439203 438925 5. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7.15 You query the LINE_ITEM table and a value of 5 is returned.25 543949 349302 453235 4.2) . Which SQL statement did you execute? Mark for Review (1) Points SELECT COUNT(discount) FROM line_item. (*) SELECT SUM(discount) FROM line_item. SELECT COUNT(*) FROM line_item. SELECT COUNT(*) FROM employees WHERE salary < 50000. SELECT * FROM employees WHERE salary < 50000.000? Which SELECT would you use? Mark for Review (1) Points SELECT * FROM employees WHERE salary > 50000. .DEPARTMENT_ID NUMBER(9) You need to display the number of employees whose salary is greater than $50. SELECT COUNT(*) FROM employees WHERE salary > 50000. first_name. department_id. last_name. Evaluate this SELECT statement: SELECT COUNT(*) FROM products. 59. 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.(*) SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id. . salary. Evaluate this statement: SELECT department_id. Mark for Review (1) Points (Choose all correct answers) SELECT department_id. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. An error occurs because no WHERE clause is included in the SELECT statement. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. Which clauses restricts the result? Choose two.An error occurs due to an error in the SELECT clause. AVG(salary) . 60. Which SELECT statement will produce the desired result? Mark for Review (1) Points . Primary Key TEAM_NAME VARCHAR2 (25) You need to create a report that lists the names of each team with more than five pitchers.WHERE job_id <> 69879 (*) GROUP BY job_id. department_id HAVING AVG(salary) > 35000 (*) 61. 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. The PLAYERS and TEAMS tables contain these columns: PLAYERS PLAYER_ID NUMBER NOT NULL. team_id = t. COUNT(p. COUNT(p.team_name.team_name.position) = 'PITCHER' GROUP BY t.player_id) FROM players p JOIN teams t ON (p.team_id) WHERE UPPER(p.position) = 'PITCHER' GROUP BY t.position) = 'PITCHER' HAVING COUNT(p.team_name. COUNT(p. . teams t ON (p.player_id) FROM players JOIN teams t ON (p.player_id) > 5. SELECT t.SELECT t.team_id = t.team_id) WHERE UPPER(p.team_id = t.team_name.player_id) FROM players p.player_id) FROM players p. SELECT t.player_id) > 5.position) = 'PITCHER' GROUP BY t.team_id) WHERE UPPER(p.team_id = t.team_name HAVING COUNT(p.team_name HAVING COUNT(p.player_id) > 5. SELECT t. teams t ON (p.team_name.team_id) WHERE UPPER(p. COUNT(p. 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. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. (*) SELECT location_id.(*) 62. . Which SELECT statement should you use? Mark for Review (1) Points SELECT location_id. COUNT(DISTINCT type) FROM manufacturer. 2) Which two clauses represent valid uses of aggregate functions? (Choose three. 3.SELECT location_id. The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8. COUNT(DISTINCT type) FROM manufacturer GROUP BY type. SELECT location_id. COUNT(type) FROM manufacturer GROUP BY location_id.) Mark for Review (1) Points (Choose all correct answers) . 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. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) 65. you use should a WHERE clause. (*) You can use a column alias in a GROUP BY clause.ORDER BY AVG(salary) GROUP BY MAX(salary) (*) SELECT AVG(NVL(salary. . dept_id FROM employee GROUP BY dept_id. You must use the HAVING clause with the GROUP BY clause. Evaluate this SELECT statement: SELECT SUM(salary). 66. 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 . rows are not sorted when a GROUP BY clause is used.By default. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. department_id.Descending order by cumulative salary 67. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing. name.2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. . id_number. The EMPLOYEES table contains these columns: ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER SALARY NUMBER (7. name ORDER BY hire_date. (*) Incorrect Incorrect. Refer to Section 6 Previous 68.2) OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) . The HIRE_DATE column is NOT included in the GROUP BY clause. The SALARY column is NOT included in the GROUP BY clause.The WHERE clause contains a syntax error. Page 67 of 100 Next Summary Examine the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8. (*) Incorrect Incorrect. You need to display all the orders that were placed on a certain date. You need to display each date that a customer placed an order. Refer to Section 6 .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 all the orders that were placed on the same day as order number 25950.CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. 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.Previous Page 68 of 100 Next Summary 69. (*) . 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). 71. SELECT product_name FROM (SELECT AVG(cost) FROM product) WHERE cost > AVG(cost). product_name FROM products WHERE cost > AVG(cost) GROUP by product_name. Using a subquery in which clause will return a syntax error? Mark for Review (1) Points WHERE . (*) 72.FROM HAVING There are no places you cannot place subqueries. Which comparison operator should you use? Mark for Review (1) Points = > <= >= (*) . You need to display all the players whose salaries are greater than or equal to John Brown's salary. and ORDERS tables. EMPLOYEE EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) DEPARTMENT . Examine the structure of the EMPLOYEE.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. DEPARTMENT. DEPARTMENT_ID NUMBER(9) DEPARTMENT_NAME VARCHAR2(25) CREATION_DATE DATE ORDERS ORDER_ID NUMBER(9) EMPLOYEE_ID NUMBER(9) DATE DATE CUSTOMER_ID NUMBER(9) You want to display all employees who had an order after the Sales department was established. Which of the following constructs would you use? Mark for Review (1) Points a group function a single-row subquery (*) the HAVING clause a MERGE statement . Which operator or keyword cannot be used with a multiple-row subquery? Review (1) Points Mark for ALL ANY . (*) 76. The <> operator returns the same result as the ANY operator in a subquery. 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 can be used when a single-row subquery returns only one row.75. 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 .= (*) > 77. All the rows in the PLAYER table would be returned by the outer query. 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 inner query would be returned. Evaluate this SELECT statement: SELECT player_id.78. name FROM players WHERE team_id IN (SELECT team_id &nbspFROM teams &nbspWHERE team_id > 300 AND salary_cap > 400000). (*) A syntax error in the outer query would be returned. . (*) No rows will be selected. subquery? (1) Points What would happen if you attempted to use a single-row operator with a multiple-row Mark for Review An error would be returned. The data returned may or may not be correct. Incorrect 80. Incorrect. All the rows will be selected. Refer to Section 6 Which best describes a multiple-row subquery? Mark for Review (1) Points A query that returns only one row from the inner SELECT statement .79. 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.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.2) MANUFACTURERS: ID NUMBER PK NAME VARCHAR2(30) LOCATION VARCHAR2(20) Which SQL statement correctly uses a subquery? Mark for Review (1) Points .2) PRICE NUMBER(5. SELECT parts_name. SELECT parts_name.UPDATE parts SET price = price * 1.manufacturers_id)).15 WHERE manufacturers_id = (SELECT id &nbspFROM manufacturers &nbspWHERE UPPER(location) IN('ATLANTA '. 'DALLAS ')). 'BOSTON '. price.id = p. cost FROM parts WHERE manufacturers_id != (SELECT id &nbspFROM manufacturers &nbspWHERE LOWER(name) = 'cost plus'). price. . cost FROM parts WHERE manufacturers_id IN (SELECT id &nbspFROM manufacturers m &nbspJOIN part p ON (m. (*) SELECT parts_name FROM (SELECT AVG(cost) &nbspFROM manufacturers) &nbspWHERE 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? Review (1) Points Mark for Equal to any member in the list . (*) Single-row operators can be used with both single-row and multiple-row subqueries. Which statement about single-row and multiple-row subqueries is true? Review (1) Points Mark for Multiple-row subqueries cannot be used with the LIKE operator.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. Multiple-row subqueries can only be used in SEL . Multiple-row subqueries can be used with both single-row and multiple-row operators. The ANY operator can be used with the LIKE and IN operators. You need to create a SELECT statement that contains a multiple-row subquery.true? 84. which comparison operator(s) can you use? Mark for Review (1) Points IN. (*) The ANY operator can be used with the DISTINCT keyword. 85. Which statement about the ANY operator when used with a multiple-row subquery is Mark for Review (1) Points The ANY operator compares every value returned by the subquery. and ALL (*) LIKE . The ANY operator is a synonym for the ALL operator. ANY. . =. and > 86. Which multiple-row comparison operator could you use? Mark for Review (1) Points >ANY (*) NOT=ALL IN >IN 87. <.. You need to display all the products that cost more than the maximum cost of every product produced in Japan.AND.BETWEEN.. The STUDENTS table contains these columns: .. (*) An error occurs because the FT_STUDENTS table already exists. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id. . into the new table. dob. 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. enroll_date FROM students WHERE UPPER(stu_type_id) = 'F').You want to insert all fulltime students. stu_type_id.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. first_name. named FT_STUDENTS. who have a STU_TYPE_ID value of "F". last_name. with an identical structure. What row data did you add to the table? Mark for Review (1) Points .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. 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. 10).'6-foot nylon leash'. 88. Because the new customer has not had a credit check. 89. you should not add an amount to the CREDIT column.The row was created with the correct data in all three columns. No data ended up in the correct columns. The row was created completely wrong. The row was created with the correct data in one of the three columns. You have been instructed to add a new customer to the CUSTOMERS table. 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 . (*) The row was created with the correct data in two of three columns. 0. samerica). 'samerica'). null. location) (200. InterCargo. 'samerica'). company. poc. 0. 'InterCargo'. 'tflanders'. (*) INSERT INTO customers VALUES (200. tflanders. 'samerica'). poc. Which DML statement should you use? for Review Mark . 'InterCargo'. credit. 'tflanders'.(1) Points (Choose all correct answers) INSERT INTO customers (cust_id. 'tflanders'. INSERT INTO customers VALUES (200. 90. company. 'InterCargo'. (*) INSERT INTO customers VALUES (cust_id. You need to add a row to an existing table. location) VALUES (200. (1) Points UPDATE INSERT (*) DELETE CREATE 91. Which clause should you include in the UPDATE statement to update multiple columns? Mark for Review (1) Points the USING clause the ON clause . You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table using one UPDATE statement. Janet is the only person with the last name of Roper that is employed by the company. One of the sales representatives. The EMPLOYEES table contains these columns and all data is stored in lowercase: EMP_ID NUMBER(10) PRIMARY KEY LNAME VARCHAR2(20) . Janet Roper. What keyword in an UPDATE statement speficies the columns you want to change? for Review (1) Points Mark SELECT WHERE SET (*) HAVING 93. has informed you that she was recently married. Her new last name is Cooper.the WHERE clause the SET clause (*) 92. and she has requested that you update her name in the employee database. 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'. . 94. Which two commands can be used to modify existing data in a database row? Review (1) Points Mark for (Choose all correct answers) DELETE INSERT (*) SELECT .UPDATE employees SET cooper = 'lname' WHERE lname = 'roper'. DELETE 'jones' FROM employees.UPDATE (*) 95. (*) DELETE FROM employees WHERE lname = 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 id_num = 348. You need to delete a record in the EMPLOYEES table for Tim Jones. . Incorrect.Incorrect 96. . Refer to Section 7 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. 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. (*) Incorrect 96. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher.2) CLASS_ASSIGNMENTS CLASS_ID NUMBER(5) . Refer to Section 7 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. Incorrect. You need to display the names of the teachers who teach classes that start within the next week.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. (*) 97. Primary Key . Examine the structures of the PRODUCTS and SUPPLIERS tables: SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. 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. 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. Which script should you use? Mark for Review (1) Points DELETE FROM products WHERE supplier_id IN (SELECT supplier_id .SUPPLIER_NAME VARCHAR2 (25) ADDRESS VARCHAR2 (30) CITY VARCHAR2 (25) REGION VARCHAR2 (10) POSTAL_CODE VARCHAR2 (11) PRODUCTS PRODUCT_ID NUMBER NOT NULL. 97. DELETE FROM products WHERE supplier_id IN (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA'). DELETE FROM products WHERE supplier_id = (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA'). Examine the structures of the PRODUCTS and SUPPLIERS tables: . (*) DELETE FROM products WHERE UPPER(city) = 'ATLANTA'.FROM suppliers WHERE UPPER(city) = 'ATLANTA'). What would happen if you issued a DELETE statement without a WHERE clause? for Review (1) Points Mark . 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. 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. Which script should you use? Mark for 98.SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. (*) An error message would be returned. No rows would be deleted. 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. Incorrect Incorrect. Only one row would be deleted.All the rows in the table would be deleted.2) . Refer to Section 7 99. (*) . Which statement should you execute? Mark for Review (1) Points UPDATE employee SET salary = SELECT salary FROM employee WHERE emp_id = 89898. all employees in department 10 have the same salary value. UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898) WHERE dept = 10.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.BONUS NUMBER(9. Currently. UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898). '37777'). J. 'Nashville'. Test: Mid Term Exam . TN.Database Programming with SQL . INSERT INTO customers VALUES '3178' 'J. Smith 123 Main Street Nashville TN 37777. Nashville.'. 123 Main Street. '123 Main Street'. INSERT INTO customers VALUES ('3178'..UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10).' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777'. 'TN'. Smith. 'J. for Review (1) Points Which of the following represents the correct syntax for an INSERT statement? Mark INSERT VALUES INTO customers (3178 J. 37777. 'Smith'. 100. (*) INSERT customers VALUES 3178. Review your answers. and question scores below. Which three statements about functions are true? (Choose three. An asterisk (*) indicates a correct answer.) Mark for Review (1) Points (Choose all correct answers) . feedback. 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. Section 1 Lesson 1 (Answer all questions in this section) 1. CONCAT . The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length.The SYSDATE function returns the Oracle Server date and time. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. (*) Correct 3. SUBSTR. (*) The CONCAT function can only be used on character strings. 5) "ID" FROM employee. not on numbers. In which order are the functions evaluated? Mark for Review (1) Points LOWER. (*) The ROUND number function rounds a value to a specified decimal place or the nearest whole number. first_name)). 1. CONCAT. CONCAT.LOWER. 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 . SUBSTR SUBSTR. SUBSTR. LOWER CONCAT. You need to return a portion of each employee's last name. LOWER (*) Correct 4. You issue this SQL statement: SELECT INSTR ('organizational sales'. LPAD(salary. Which value is returned by this command? Mark for Review (1) Points 1 2 13 (*) 17 Correct 6.5. What will the following SQL statemtent display? SELECT last_name. '$')SALARY . 'al') FROM dual. 15. leftpadded with the $ and the column labeled SALARY. size of 15 and the column labeled SALARY.FROM employees. Evaluate this SELECT statement: SELECT LENGTH(email) FROM employee." Correct 7. The last name and the format of the salary limited to 15 digits to the left of the decimal and the column labeled SALARY. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value. The last name and salary for all employees with the format of the salary 15 characters long. (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. . Which two functions can be used to manipulate number or date column values. but NOT character column values? (Choose two.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 maximum number of characters allowed in the EMAIL column.) Mark for Review (1) Points (Choose all correct answers) . The number of characters for each value in the EMAIL column in the employees table. Correct Section 1 Lesson 2 (Answer all questions in this section) 8. . 'MONTH') FROM employee.RPAD TRUNC (*) ROUND (*) INSTR CONCAT Correct 9. 'MONTH') FROM employee. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review (1) Points SELECT TRUNC(hire_date. (*) SELECT ROUND(hire_date. SELECT TRUNC(hire_date.367. Which value does this statement display? Mark for Review (1) Points 700 .-1) FROM dual. Refer to Section 1 Lesson 3 10. You issue this SQL statement: SELECT TRUNC(751. 'MON') FROM employee. Incorrect. 'MI') FROM employee.SELECT ROUND(hire_date. and question scores below.Database Programming with SQL Review your answers.3 Correct Page 1 of 10 Test: Mid Term Exam . An asterisk (*) indicates a correct answer. Which SELECT statement will NOT return a date value? Mark for Review (1) Points . Section 1 Lesson 3 (Answer all questions in this section) 11. feedback.750 (*) 751 751. SELECT (hire_date . (*) SELECT SYSDATE . Correct 12. Which function should you use? Mark for Review (1) Points ROUND .hire_date) + 10*8 FROM employees.TO_DATE('25-JUN-02') + hire_date FROM employees.SELECT (30 + hire_date) + 1440/24 FROM employees.SYSDATE) + TO_DATE('25-JUN-02') FROM employees. You need to subtract three months from the current date. SELECT (SYSDATE . 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 . Which value is returned by the query? Mark for Review (1) Points .14. 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. You need to display the current year as a character value (for example: Two Thousand and One). Each employee's salary must be displayed in the following format: $000.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.000. 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.00. Which function should you include in a SELECT statement to achieve the desired result? Mark for Review (1) Points TO_CHAR (*) TO_DATE . Correct Section 2 Lesson 1 (Answer all questions in this section) 16. TO_NUMBER CHARTOROWID Correct 17. The TO_CHAR function can be used to remove text from column data that will be returned by the database. Correct . (*) The TO_CHAR function can only be used on DATE columns. 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 display dates and numbers according to formatting conventions that are supported by Oracle. Date Month. dd Month.18. total FROM customers NATURAL JOIN orders WHERE total >= 2500. dy month. Year format (For example. The report's date should be displayed in the Day. (*) . 2004 ). yyyy'). SELECT companyname. dy month. yyyy'). 'fmdd. You have been asked to create a report that lists all customers who have placed orders of at least $2.500. yyyy'). TO_CHAR (sysdate. Which statement should you issue? Mark for Review (1) Points SELECT companyname. SELECT companyname. total FROM customers NATURAL JOIN orders WHERE total >= 2500. SELECT companyname. TO_CHAR (sysdate. 'dd. Tuesday. total FROM customers NATURAL JOIN orders WHERE total >= 2500. 13 April. TO_DATE (sysdate. dd month. yyyy'). 'fmDay. 'day. total FROM customers NATURAL JOIN orders WHERE total >= 2500. TO_DATE (date. Correct 20.900.Incorrect. Single row functions cannot modify a data type. .990.99') FROM product.30"? Mark for Review (1) Points SELECT TO_CHAR(price. SELECT TO_CHAR(price. but can return multiple values. Refer to Section 2 19.99") FROM product. "$99. '$99. Which SQL Statement should you use to display the prices in this format: "$00.99') FROM product. '$99. Which statement concerning single row functions is true? Mark for Review (1) Points Single row functions can accept only one argument.99') FROM product. SELECT TO_NUMBER(price.900. '$99. (*) SELECT TO_CHAR(price.900. (*) Single row functions return one or more results per row.Single row functions can be nested.Database Programming with SQL Review your answers. Correct Page 2 of 10 Test: Mid Term Exam . Section 2 Lesson 1 (Answer all questions in this section) . An asterisk (*) indicates a correct answer. feedback. and question scores below. 000. SELECT TO_NUM(salary.990. '$999.00') FROM employees. Which script should you use to display the salaries in format: "$45. SELECT TO_NUM(salary. '$999. '$999.00"? Mark for Review (1) Points SELECT TO_CHAR(salary.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.999') FROM employees.99') FROM employees.999. . but not NVL2. NVL. but not COALESCE. can be used with group functions to replace null values. NVL and COALESCE. but not NVL and NVL2.999. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. can be used with group functions to replace null values. NVL2.00') FROM employees. '$999. (*) COALESCE. (*) Correct Section 2 Lesson 2 (Answer all questions in this section) 22. can be used with group functions to replace null values. and COALESCE can be used with group functions to replace null values.SELECT TO_CHAR(salary. 00 809090 LOAFER 89098 10. cost FROM styles WHERE style_name LIKE 'SANDAL' AND NVL(cost. style_name. Which result will the query provide? Mark for Review .00 ORDER BY category. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. category. 0) < 15. cost.00 968950 SANDAL 85909 10.00 890890 LOAFER 89789 14.Correct 23.00 869506 SANDAL 89690 15.00 857689 HEEL 85940 11.00 758960 SANDAL 86979 Evaluate this SELECT statement: SELECT style_id. 00 758960 SANDAL 86979 869506 SANDAL 89690 15.00 968950 SANDAL 85909 10.00 758960 SANDAL 86979 STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85909 12.00 .(1) Points STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 968950 SANDAL 85909 10.00 869506 SANDAL 89690 15.00 968950 SANDAL 85909 10.00 758960 SANDAL 86979 STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85909 12. STYLE_ID STYLE_NAME CATEGORY COST 968950 SANDAL 85909 10. 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 .00 758960 SANDAL 86979 (*) Correct 24.00 895840 SANDAL 85940 12. SELECT e.emp_id = s.fname. (*) SELECT e.fname.lname. e. sales WHERE e.emp_id = s.emp_id AND revenue >= 100000.emp_id AND revenue > 100000.lname. You want to identify the sales representatives who have generated at least $100. sales s WHERE e.sales FROM employees.000 in revenue. s.Section 3 Lesson 2 (Answer all questions in this section) 25. e.lname. s.sales FROM employees e.emp_id AND revenue >= 100000. Which query should you issue? Mark for Review (1) Points SELECT e. s. e.fname.sales FROM employees e.emp_id = s. . sales s WHERE e. Your have two tables named EMPLOYEES and SALES. lname. 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 .emp_id AND revenue > 100000. sales Q FROM employees e. sales s WHERE e.emp_id = s. Correct 26.SELECT fname. one column to the next column. Which statement about the join syntax of a SELECT statement is true? Mark for Review (1) Points The ON keyword must be included. 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. The JOIN keyword must be included. 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. The FROM clause represents the join criteria. .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.cust_id (+). the company and the total sales? Mark for Review (1) Points SELECT c.company. (*) Correct 29. sales s WHERE c. c.total_sales FROM customers c. s.The WHERE clause represents the join criteria. .cust_id.cust_id = s. total_sales FROM customers c.cust_id.SELECT cust_id.cust_id.cust_id = s.company. sales WHERE cust_id = cust_id. company. total_sales FROM customers. c. Correct 30.cust_id = s.000 per year. s.cust_id. (*) SELECT cust_id. company. Which query should you issue to accomplish this task? Mark for Review (1) Points . You need to create a report that lists all employees in the Sales department who do not earn $25. sales s WHERE c. sales s WHERE c. total_sales FROM customers c. SELECT c. salary FROM employees WHERE salary != 25000 AND dept_id = 10. first_name. first_name.SELECT last_name. salary FROM employees WHERE salary = 25000 AND dept_id = 10. SELECT last_name. SELECT last_name. (*) Correct . first_name. salary FROM employees WHERE salary <= 25000 AND dept_id = 10. first_name. salary FROM employees WHERE salary > 25000 AND dept_id = 10. SELECT last_name. . 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.Database Programming with SQL Review your answers.. An asterisk (*) indicates a correct answer.Page 3 of 10 Test: Mid Term Exam .. Section 3 Lesson 4 (Answer all questions in this section) 31. and question scores below.. feedback. and IN . Which of the following best describes the function of an outer join? Mark for Review (1) Points .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. 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. An outer join will return only data from the far left column in one table and the far right column in the other table. Which type of join should you create? Mark for Review (1) Points An equijoin A cross join (*) .An outer join will return only those rows that do not meet the join criteria. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table. Columns with the same names cannot be included in the SELECT list of the query. 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 compatible data types. Columns with the same names must have the same precision and datatype. 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 . Correct 36.An inner join A full outer join Correct 35. (1) Points (Choose all correct answers) Equijoin (*) Self join (*) Nonequijoin Simple join (*) full outer join Incorrect. Evaluate this SELECT statement: . Refer to Section 4 Section 4 Lesson 3 (Answer all questions in this section) 37. Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b.patient_id) Correct 38. ' || b.lname || '. b.admission FROM patient a JOIN physician b ON (b.physician_id = c. c. ' || a. (*) JOIN admission c ON (a.patient_id = c.patient_id).patient_id = c.fname as "Patient".SELECT a.lname || '.physician_id).physician_id = c.physician_id).fname as "Physician". JOIN admission c ON (a. Which of the following statements is the simplest description of a nonequijoin? Mark for Review (1) Points . 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 (*) . A join condition that includes the (+) on the left hand side. A join that joins a table to itself Correct 39.A join condition containing something other than an equality operator (*) A join condition that is not equal to other joins. (*) The ORDER table contains a column that has a referential constraint to a column in the PRODUCT table. Correct Page 4 of 10 . CUST_ID. The CUSTOMER and ORDER tables have a corresponding column.Correct 40. The CUSTOMER and ORDER tables have no columns with identical names. The CUST_ID column in the ORDER table contains null values that need to be displayed. 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. Test: Mid Term Exam . Refer to Section 4 .Database Programming with SQL Review your answers. Section 4 Lesson 4 (Answer all questions in this section) 41. An asterisk (*) indicates a correct answer. feedback. and question scores below. 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. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e. d.department_id.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e. .42.department_id).department_id = d. 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. e.last_name. Which query will retrieve all the rows in the EMPLOYEES table. e. d.department_id.department_id = d.SELECT e.department_name FROM employees e LEFT OUTER JOIN departments d ON (e. e. d.department_name FROM employees e JOIN departments d USING (e.last_name.department_id).department_id. SELECT e. (*) SELECT e. d.department_id).department_id = d. Correct Section 5 Lesson 1 (Answer all questions in this section) .department_name FROM employees e NATURAL JOIN departments d.department_id.last_name. e.last_name. Displays each job id and the number of people assigned to that job id. Correct 45. Mark for Review (1) Points Displays all the employees and groups them by job. Displays all the jobs with as many people as there are jobs. AVG (salary)"Average" FROM employees GROUP BY Department. (*) Displays only the number of job_ids. What will the following SQL Statement do? SELECT job_id.44. Mark for Review . COUNT(*) FROM employees GROUP BY job_id. What is the best explanation as to why this SQL statement will NOT execute? SELECT department_id "Department". (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. The GROUP BY clause can contain an aggregate function. A GROUP BY clause cannot be used without an ORDER BY clause. 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. Correct 46. You cannot use a column alias in the GROUP BY clause. The department id is not listed in the departments table. (*) The GROUP BY clause must have something to GROUP. . Group functions can be nested to a depth of? Mark for Review (1) Points three four two (*) Group functions cannot be nested.Correct 47. number and date data types? . Correct Section 5 Lesson 2 (Answer all questions in this section) 48. Which group functions below act on character. Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) . You need to calculate the standard deviation for the cost of products produced in the Birmingham facility.(Choose more than one answer) Mark for Review (1) Points (Choose all correct answers) SUM MAX (*) MIN (*) AVG COUNT (*) Correct 49. 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. The CUSTOMER table contains these columns: CUSTOMER_ID NUMBER(9) FNAME VARCHAR2(25) LNAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7.VAR_SAMP VARIANCE Correct 50.2) CATEGORY VARCHAR2(20) You need to calculate the average credit limit for all the customers in each category. Which group function should you use to calculate this value? Mark for Review (1) Points AVG (*) SUM . Section 5 Lesson 2 (Answer all questions in this section) .COUNT STDDEV Correct Page 5 of 10 Test: Mid Term Exam . and question scores below.Database Programming with SQL Review your answers. feedback. An asterisk (*) indicates a correct answer. 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.51. Which group function would you use to display the highest salary value in the EMPLOYEE table? Mark for Review (1) Points AVG COUNT MAX (*) . 00 89453485 8549038 15-FEB-03 INTEREST 596. (*) SELECT AVG(payment_amount) FROM payment.00 85490345 5489304 20-MAR-03 BASIC 568.00 You need to determine the average payment amount made by each customer in January. 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'. February and March of 2003. .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. SELECT AVG(payment_amount) FROM payment WHERE TO_CHAR(payment_date) IN (JAN.2) HIRE_DATE DATE BONUS NUMBER(7.SELECT SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'.2) . MAR). FEB. Correct 54.2) COMM_PCT NUMBER(4. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(9. or SALARY columns? (Choose three. Mark for Review (1) Points a row set. ignore (*) .) Mark for Review (1) Points (Choose all correct answers) MAX (*) SUM AVG MIN (*) COUNT (*) Correct 55. LAST_NAME. Group functions return a value for ________________ and ________________ null values in their computations.Which three functions could be used with the HIRE_DATE. The COUNT function always ignores null values by default.each row. ignore a row set. (*) The COUNT function can be used to find the maximum value in each column. 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. include each row. . SELECT * FROM employees WHERE salary < 50000. non-null values in a column. Incorrect.The COUNT function can be used to determine the number of unique.000? Which SELECT would you use? Mark for Review (1) Points SELECT * FROM employees WHERE salary > 50000. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7. Refer to Section 5 57. .2) DEPARTMENT_ID NUMBER(9) You need to display the number of employees whose salary is greater than $50. first_name. Group functions can avoid computations involving duplicate values by including which keyword? Mark for Review (1) Points NULL DISTINCT (*) . department_id. (*) SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id.SELECT COUNT(*) FROM employees WHERE salary < 50000. last_name. salary. SELECT COUNT(*) FROM employees WHERE salary > 50000. Correct 58. 25 0. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT 890898 847589 848399 8.60 954039 439203 438925 5.05 867950 985490 945809 5. (*) .99 0.15 543949 349302 453235 4. Which SQL statement did you execute? Mark for Review (1) Points SELECT COUNT(discount) FROM line_item.10 768385 862459 849869 5.SELECT UNLIKE Correct 59. SELECT COUNT(*) FROM line_item.60 0.50 You query the LINE_ITEM table and a value of 5 is returned. 2) PRICE NUMBER(7.SELECT SUM(discount) FROM line_item.00. 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. You need to include only the products that have a price less than $25. Which SQL statement will display the desired result? . The extended cost of each item equals the quantity value multiplied by the cost value. Correct Section 6 Lesson 1 (Answer all questions in this section) 60.2) QUANTITY NUMBER You display the total of the extended costs for each product category by location. SELECT AVG(discount) FROM line_item. Mark for Review (1) Points SELECT category_id.00 GROUP BY category_id. location_id. (*) SELECT SUM(cost * quantity) TOTAL FROM products WHERE price < 25.location_id FROM products WHERE price > 25.00. location_id.00 GROUP BY category_id. . location_id FROM products WHERE price < 25. SUM(cost * quantity) TOTAL. SUM(cost * quantity) TOTAL.00 GROUP BY location_id. SELECT SUM(cost * quantity) TOTAL. SELECT category_id. location_id FROM products WHERE price < 25. Refer to Section 6 Page 6 of 10 Test: Mid Term Exam . Evaluate this SELECT statement: SELECT SUM(salary).Database Programming with SQL Review your answers. and question scores below. feedback. An asterisk (*) indicates a correct answer.Incorrect. Section 6 Lesson 1 (Answer all questions in this section) 61. 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.FROM employee GROUP BY dept_id.2) . The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8. Evaluate this SELECT statement: SELECT SUM(salary).Which two clauses represent valid uses of aggregate functions? (Choose three. mgr_id FROM employee GROUP BY dept_id. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Correct 63. mgr_id.) Mark for Review (1) Points (Choose all correct answers) ORDER BY AVG(salary) GROUP BY MAX(salary) (*) SELECT AVG(NVL(salary. . dept_id. Which SELECT statement clause allows you to restrict the rows returned. Which SELECT statement should you use? Mark for Review . 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. 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. Refer to Section 6 64. Refer to Section 6 . SELECT location_id. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. Incorrect. COUNT(DISTINCT type) FROM manufacturer. COUNT(DISTINCT type) FROM manufacturer GROUP BY type. SELECT location_id. (*) SELECT location_id.(1) Points SELECT location_id. COUNT(type) FROM manufacturer GROUP BY location_id. 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. department_name FROM employee WHERE dept_id = 1 GROUP BY department. Which statement about the GROUP BY clause is true? Mark for Review (1) Points . Evaluate this SELECT statement: SELECT SUM(salary). dept_id.65. You must use the HAVING clause with the GROUP BY clause. By default. you use should a WHERE clause. COUNT(payment_id) FROM payment . Correct 67. rows are not sorted when a GROUP BY clause is used. 2003 ? Mark for Review (1) Points SELECT customer_id. (*) You can use a column alias in a GROUP BY clause. 2003 and June 30.To exclude rows before dividing them into groups using the GROUP BY clause. 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. SELECT 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'. Incorrect. SELECT customer_id. Refer to Section 6 .WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. Section 6 Lesson 2 (Answer all questions in this section) 68. Correct 69. after the main or outer query executes. Subqueries are often used in a WHERE clause to return values for an unknown conditional value. Which operator can be used with subqueries that return only one row? Mark for Review (1) Points LIKE (*) . (*) Subqueries generally execute last. Which statement about subqueries is true? Mark for Review (1) Points Subqueries should be enclosed in double quotation marks. Subqueries cannot contain group functions. 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 .ANY ALL IN Correct 70. Which comparison operator should you use? Mark for Review (1) Points = > <= . and question scores below.Database Programming with SQL Review your answers. feedback. 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. An asterisk (*) indicates a correct answer.Page 7 of 10 Test: Mid Term Exam . >= (*) Correct 72.2) Which of the following scenarios would require a subquery to return the desired results? Mark for Review (1) Points . 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. Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT * FROM employees WHERE supervisor_id = (SELECT supervisor_id . you are not sure which supervisor ID belongs to Brad Carter.You need to display the date each customer account was opened. You need to display all the orders that were placed on a certain date. You need to display each date that a customer placed an order. However. (*) 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. You need to display all the orders that were placed on the same day as order number 25950. FROM employees WHERE last_name = 'Carter'). SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id FROM supervisors WHERE last_name = 'Carter'). SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees . DEPARTMENT. Examine the structure of the EMPLOYEE.WHERE last_name = 'Carter'). (*) Correct 74. 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) . and ORDERS tables. 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. 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 .You want to display all employees who had an order after the Sales department was established. Refer to Section 6 75. 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.00). . name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. Evaluate this SELECT statement: SELECT customer_id. (*) All the rows in the table would be selected.No rows would be returned by the outer query. 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 . Only the rows with CUSTOMER_ID values equal to null would be selected. Correct 77. SELECT description FROM d_types WHERE code <> ALL (SELECT type_code FROM d_songs). (*) Correct . SELECT description FROM d_types WHERE code = ANY (SELECT type_code FROM d_songs). 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).78. All of the above. 00 85490345 5489304 20-MAR-03 BASIC 568. (*) Remove the quotes surrounding the date value in the OR clause.00 This statement fails when executed: SELECT customer_id. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859. Remove the parentheses surrounding the nested SELECT statement.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'. payment_type FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_amount = 596. .00 89453485 8549038 15-FEB-03 INTEREST 596.79. Mark for Review (1) Points Single rows contain multiple values and a logical operator is used. Nothing.Change the comparison operator to a single-row operator. (*) Subquery references the wrong table in the WHERE clause. Correct 80. last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). What is wrong with the following query? SELECT employee_id. . it will run without problems. Subquery returns more than one row and single row comparison operator is used. An asterisk (*) indicates a correct answer.Correct Page 8 of 10 Test: Mid Term Exam . feedback. Evaluate this SELECT statement: SELECT player_id. Section 6 Lesson 4 (Answer all questions in this section) 81. name FROM players WHERE team_id IN (SELECT team_id .Database Programming with SQL Review your answers. and question scores below. 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. first_name FROM customer WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). . A syntax error in the inner query would be returned. Evaluate this SELECT statement that includes a subquery: SELECT last_name. All the rows in the PLAYER table would be returned by the outer query. (*) A syntax error in the outer query would be returned. Correct 82. 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.Which statement is true about the given subquery? Mark for Review (1) Points The outer query executes before the nested subquery. Correct 83. . Both the inner and outer queries must return a value. Multiple-row subqueries can be used with both single-row and multiple-row operators. (*) Single-row operators can be used with both single-row and multiple-row subqueries. (*) An error occurs if the either the inner or outer queries do not return a value. The results of the inner query are returned to the outer query. or an error occurs. which comparison operator(s) can you use? Mark for Review (1) Points IN. and > Correct 85. <. and ALL (*) LIKE BETWEEN... =.Multiple-row subqueries can only be used in SELECT statements.. Which statement about the ANY operator when used with a multiple-row subquery is true? Mark for Review (1) Points .. You need to create a SELECT statement that contains a multiple-row subquery. Correct 84.AND. ANY. The data returned may or may not be correct.The ANY operator compares every value returned by the subquery. Correct . The ANY operator is a synonym for the ALL operator. (*) No rows will be selected. 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. (*) The ANY operator can be used with the DISTINCT keyword. The ANY operator can be used with the LIKE and IN operators. Correct 86. All the rows will be selected. Section 7 Lesson 1 (Answer all questions in this section) 87. 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) . You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. 09. 8690. 'Cable'). you should not add an amount to the CREDIT column. 7. product_name. 8690. product_name) VALUES (2958.SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. INSERT INTO products(product_id. The CUSTOMERS table contains these columns: . 'Cable'. 700). INSERT INTO products(product_id.04. Correct 89. 'Cable'.04.09. (*) INSERT INTO products VALUES (2958. Because the new customer has not had a credit check.2) COST NUMBER (5. 8690. SYSDATE). 4. You have been instructed to add a new customer to the CUSTOMERS table.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. supplier_id VALUES (2958. SYSDATE). 7. 4. 'Cable'. 'samerica'). credit. (*) INSERT INTO customers VALUES (cust_id. null. 'InterCargo'. 'samerica'). poc. 'tflanders'. 'tflanders'. poc. (*) INSERT INTO customers VALUES (200. 'InterCargo'. 'tflanders'. 'InterCargo'. location) (200. company. 0. . company. 'samerica'). location) VALUES (200.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. 0. The following SQL statement will execute which of the following? INSERT INTO departments (department_id. samerica). tflanders. Assume all the column names are correct. 100.INSERT INTO customers VALUES (200. InterCargo. department_name. 'Public Relations'. manager_id. Correct 90. 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 . location_id) VALUES (70. Database Programming with SQL Review your answers. and question scores below.Correct Page 9 of 10 Test: Mid Term Exam . An asterisk (*) indicates a correct answer. Section 7 Lesson 2 (Answer all questions in this section) 91. feedback. 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 . her last name is now Rockefeller. however. Her employee ID is still 189. UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. One of your employees was recently married.INSERT with a WHERE clause DELETE with a WHERE clause (*) MERGE with a WHERE clause Correct 92. (*) Correct . 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 Correct 94. You want to enter a new record into the CUSTOMERS table.93.2) . CREATE INSERT. CREATE MERGE. 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. MERGE (*) INSERT. Which two commands can be used to create new rows? Mark for Review (1) Points INSERT.2) BONUS NUMBER(9. Which statement should you use? Mark for Review (1) Points UPDATE employees SET salary = salary * 1.15 WHERE dept = 10.10.10. bonus = bonus * .15) WHERE dept = 10. UPDATE employees SET salary = salary * . .15 WHERE dept = 10.10) SET (bonus = bonus * 1. You also need to increase the bonus for all employees in department 10 by 15 percent.10 AND bonus = bonus * 1. (*) UPDATE employees SET salary = salary * 1. UPDATE employees SET (salary = salary * 1.15 WHERE dept = 10.You need to increase the salary for all employees in department 10 by 10 percent. bonus = bonus * 1. Incorrect. Her new last name is Cooper. Refer to Section 7 95. Janet is the only person with the last name of Roper that is employed by the company. has informed you that she was recently married. (*) UPDATE employees lname = 'cooper' WHERE lname = 'roper'. Janet Roper. One of the sales representatives. and she has requested that you update her name in the employee database. 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 SET cooper = 'lname' WHERE lname = 'roper'. Correct 96. (*) An error message would be returned. 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. . No rows would be deleted.UPDATE employees SET lname = 'roper' WHERE lname = 'cooper'. '37777'). 'Nashville'. Nashville. 'Smith'.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777'. J. 37777. The PLAYERS table contains these columns: PLAYER_ID NUMBER NOT NULL PLAYER_LNAME VARCHAR2(20) NOT NULL PLAYER_FNAME VARCHAR2(10) NOT NULL . 'TN'. Smith.. INSERT INTO customers VALUES '3178' 'J. Correct 98. 123 Main Street. Smith 123 Main Street Nashville TN 37777.Only one row would be deleted. Which of the following represents the correct syntax for an INSERT statement? Mark for Review (1) Points INSERT VALUES INTO customers (3178 J. 'J.'. INSERT INTO customers VALUES ('3178'. (*) INSERT customers VALUES 3178. Correct 97. TN. '123 Main Street'. In which clause of the UPDATE statement will you specify this condition? Mark for Review (1) Points the ON clause .125) WHERE team_id = 5960. (*) UPDATE players (salary) VALUES(salary * 1. You need to update the expiration date of products manufactured before June 30th .5 percent. UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960.2) You need to increase the salary of each player for all players on the Tiger team by 12. UPDATE players SET salary = salary * . Which statement should you use? Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1.125 WHERE team_id = 5960.125.TEAM_ID NUMBER SALARY NUMBER(9. The TEAM_ID value for the Tiger team is 5960. Correct 99. .the WHERE clause (*) the SET clause the USING clause Correct 100. You need to delete a record in the EMPLOYEES table for Tim Jones. 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. whose unique employee identification number is 348. (*) DELETE FROM employees WHERE lname = jones. Correct Page 10 of 10 1.DELETE * FROM employees WHERE id_num = 348. 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 (*) . DELETE 'jones' FROM employees. The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length. (*) The ROUND number function rounds a value to a specified decimal place or the nearest whole number. not on numbers. (*) The CONCAT function can only be used on character strings.) Mark for Review (1) Points (Choose all correct answers) The SYSDATE function returns the Oracle Server date and time.Correct 2. Which three statements about functions are true? (Choose three. (*) Correct You query the database with this SQL statement: . CONCAT. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. LOWER (*) Correct 4. LOWER CONCAT. CONCAT LOWER. 5) "ID" FROM employee. 1. CONCAT.00 968950 SANDAL 85909 10. In which order are the functions evaluated? Mark for Review (1) Points LOWER. SUBSTR SUBSTR. SUBSTR. first_name)).00 . SUBSTR.SELECT LOWER(SUBSTR(CONCAT(last_name. 2. SELECT SUBSTR(category.2) FROM styles WHERE style_id = 895840.2) FROM styles WHERE style_id = 895840. 2.00 758960 SANDAL 86979 11.2) FROM styles WHERE style_id = 895840. SELECT INSTR(category.00 You query the database and return the value 40.00 890890 LOAFER 89789 14. (*) . Which script did you use? Mark for Review (1) Points SELECT INSTR(category.00 809090 LOAFER 89098 10.869506 SANDAL 89690 15. -2.00 857689 HEEL 85940 11. SELECT SUBSTR(category. Correct You issue this SQL statement: SELECT INSTR ('organizational sales'. 'al') FROM dual.2) FROM styles WHERE style_id = 758960. Which value is returned by this command? Mark for Review (1) Points 1 2 13 (*) . -2. 17 Correct 6. '$')SALARY FROM employees. . 15. Which function should you use? Mark for Review (1) Points LENGTH (*) LPAD COUNT SUBSTR Correct 7. LPAD(salary. What will the following SQL statemtent display? SELECT last_name. You need to display the number of characters in each customer's last name. size of 15 and the column labeled SALARY. -2) FROM dual.Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value. What value does this statement produce? Mark for Review ." Correct . (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. leftpadded with the $ and the column labeled SALARY. The last name and salary for all employees with the format of the salary 15 characters long. You issue this SQL statement: SELECT ROUND (1282.248. The last name and the format of the salary limited to 15 digits to the left of the decimal and the column labeled SALARY. 25 1300 (*) Correct 9.(1) Points 1200 1282 1282. 2) Which value is returned? Mark for Review (1) Points 1 (*) 2 25 0 . Evaluate this function: MOD (25. . Refer to Section 1 Lesson 1 11....Correct 10. IS NULL Incorrect. Which comparison operator retrieves a list of values? Mark for Review (1) Points IN (*) LIKE BETWEEN. Which function would you use to return the current database server date and time? Mark for Review (1) Points DATE SYSDATE (*) DATETIME .IN. You need to subtract three months from the current date. Which function should you use? Mark for Review (1) Points ROUND BETWEEN ADD_MONTHS MONTHS_BETWEEN (*) Correct 13. You need to display the number of months between today's date and each employee's hiredate.CURRENTDATE Correct 12. Which function should you use? Mark for Review (1) Points ROUND . Refer to Section 1 14. Evaluate this SELECT statement: .TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN Incorrect. 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. 30"? Mark for Review (1) Points SELECT TO_CHAR(price. Refer to Section 1 16. '$99.99') FROM product. (*) . Which SQL Statement should you use to display the prices in this format: "$00. 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.SELECT SYSDATE + 30 FROM dual.900. You have been asked to create a report that displays each employee's name and salary.99') FROM product. 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. SELECT TO_CHAR(price.990. Correct 17.000. '$99.900. "$99. All Human Resources data is stored in a table named EMPLOYEES. '$99. SELECT TO_NUMBER(price.SELECT TO_CHAR(price. The EMPLOYEES table contains these columns: . Each employee's salary must be displayed in the following format: $000.00.99") FROM product.99') FROM product.900. Refer to Section 2 18. 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. 'Month DD. YYYY) FROM employees. YYYY') FROM employees. SELECT TO_CHAR(hire_date. (*) . Month DD. 2000 Which SELECT statement could you use? Mark for Review (1) Points SELECT TO_CHAR(hire_date. (*) Number functions can return number or character values. SELECT TO_CHAR(hire_date. ' YYYY') FROM employees. Incorrect.SELECT hire_date(TO_CHAR 'Month DD'. . Refer to Section 2 19.) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. Conversion functions convert a value from one data type to another data type. Which two statements concerning SQL functions are true? (Choose two. 'Month DD'. Not all date functions return date values. (*) Single-row functions manipulate groups of rows to return one result per group of rows. ' YYYY') FROM employees. 99') FROM employees. SELECT TO_NUM(salary. Which script should you use to display the salaries in format: "$45. 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.000. '$999.999') FROM employees. '$999. . Refer to Section 2 20.00"? Mark for Review (1) Points SELECT TO_CHAR(salary.Incorrect.990. SELECT TO_CHAR(salary. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001.999. Refer to Section 2 21. (*) Incorrect.00') FROM employees. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 Correct .00') FROM employees.999. '$999. '$999.SELECT TO_NUM(salary. (*) SELECT NVL(tuition_balance. 0) "Balance Due" FROM student_accounts. tuition_balance + housing_balance "Balance Due" . 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.22. 0). 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. NVL (housing_balance). When executed. can be used with group functions to replace null values. 0). NVL. but not NVL and NVL2. SELECT TO_NUMBER(tuition_balance. TO_NUMBER (housing_balance. and COALESCE can be used with group functions to replace null values. but not NVL2. Incorrect. 0). .FROM student_accounts. (*) COALESCE. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. can be used with group functions to replace null values. NVL2. Refer to Section 2 24. can be used with group functions to replace null values. but not COALESCE. NVL and COALESCE. tutition_balance + housing_balance "Balance Due" FROM student_accounts. SELECT tuition_balance + housing_balance FROM student_accounts. Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT last_name.Correct 25. You need to create a report that lists all employees in the Sales department who do not earn $25. first_name.000 per year. salary FROM employees WHERE salary > 25000 AND dept_id = 10. . how many join conditions are needed in the WHERE clause? Mark for Review (1) Points 0 1 2 (*) 3 Correct 26. When joining 3 tables in a SELECT statement. salary FROM employees WHERE salary = 25000 AND dept_id = 10. salary FROM employees WHERE salary <= 25000 AND dept_id = 10. SELECT last_name. first_name. SELECT last_name.SELECT last_name. (*) Correct 27. first_name. The CUSTOMERS and SALES tables contain these columns: CUSTOMERS CUST_ID NUMBER(10) PRIMARY KEY COMPANY VARCHAR2(30) . first_name. salary FROM employees WHERE salary != 25000 AND dept_id = 10. 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. SELECT cust_id. total_sales FROM customers.cust_id = s.company. s. c. c.cust_id.cust_id (+).company. sales s WHERE c. SELECT c.total_sales FROM customers c. company. sales s WHERE c. sales WHERE cust_id = cust_id.cust_id.cust_id.total_sales FROM customers c. the company and the total sales? Mark for Review (1) Points SELECT c. . s.cust_id = s. cust_id.emp_id = s.(*) SELECT cust_id. e. Which query should you issue? Mark for Review (1) Points SELECT e. sales s WHERE e. sales s WHERE e.000 in revenue. s. company. e.sales FROM employees e.lname. total_sales FROM customers c.cust_id = s.emp_id AND revenue > 100000.fname.emp_id AND revenue >= 100000. sales s WHERE c.fname. You want to identify the sales representatives who have generated at least $100.lname. Correct 28.emp_id = s. Your have two tables named EMPLOYEES and SALES. s. SELECT e.sales FROM employees e. (*) . emp_id = s. sales Q FROM employees e. SELECT fname. Correct 29.lname.SELECT e.emp_id AND revenue >= 100000. lname. e.sales FROM employees.fname. exhausting all possibilities The table is joined to another equal table All rows that do not match in the WHERE clause are displayed . sales WHERE e.emp_id AND revenue > 100000. sales s WHERE e. s. one column to the next column. 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.emp_id = s. The OR operator cannot be used to link outer join conditions. The JOIN keyword must be included. The FULL. (*) . Refer to Section 3 31. or LEFT keyword must be included.Incorrect. Which statement about the join syntax of a SELECT statement is true? Mark for Review (1) Points The ON keyword must be included. RIGHT. Refer to Section 30. Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. The FROM clause represents the join criteria. (*) Incorrect. The WHERE clause represents the join criteria. last_name.team_id = t. m.team_name FROM player p LEFT OUTER JOIN player m ON (p.Outer joins are always evaluated before other types of joins in the query. 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 . m. Evaluate this SELECT statement: SELECT p.player_id) LEFT OUTER JOIN team t ON (p. t.manager_id = m.player_id.team_id). Correct 32.first_name. and IN IN and = Incorrect.AND. Refer to Section 3 34. 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...Correct 33. (*) Columns with the same names must have compatible data types.. .. Columns with the same names must have the same precision and datatype. Which statement about a natural join is true? Mark for Review (1) Points Columns with the same names must have identical data types. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table. 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 . Incorrect. Refer to Section 4 35. 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.Columns with the same names cannot be included in the SELECT list of the query. Which of the following statements is the simplest description of a nonequijoin? Mark for Review (1) Points .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. A join condition that includes the (+) on the left hand side. companyname varchar2(30). constraint pk_customers_01 primary key (custid)).A join condition containing something other than an equality operator (*) A join condition that is not equal to other joins. phone varchar2(20). address varchar2(30). A join that joins a table to itself Incorrect. . You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in sequence: CREATE TABLE customers (custid varchar2(5). city varchar2(20). CREATE TABLE orders (orderid varchar2(5) constraint pk_orders_01 primary key. contactname varchar2(30). state varchar2(30). Refer to Section 4 39. custid = c.custid = c. total FROM orders o JOIN customers c ON o. SELECT orderid. total number(15).custid WHERE city = 'Nashville'. You have been instructed to compile a report to present the information about orders placed by customers who reside in Nashville . orderdate. custid varchar2(5) references customers (custid)). Which query should you issue to achieve the desired results? Mark for Review (1) Points SELECT custid. companyname FROM customers WHERE city = 'Nashville'. (*) .custid WHERE city = 'Nashville'. SELECT orderid.orderdate date. total FROM orders o NATURAL JOIN customers c ON o. orderdate. orderdate. 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. Correct 40. total FROM orders WHERE city = 'Nashville'.2) . Below find the structure of the CUSTOMERS and SALES_ORDER tables: CUSTOMERS CUSTOMER_ID NUMBER NOT NULL.SELECT orderid. SELECT c.customer_name . (*) SELECT c.customer_id(+).customer_name FROM customers c. sales_order s WHERE c.customer_id not in (SELECT s.customer_name FROM customers c WHERE c.customer_id = s. Which statement could you use? Mark for Review (1) Points SELECT c.SALES_ORDER ORDER_ID NUMBER NOT NULL.2) SHIP_METHOD VARCHAR2 (5) You need to create a report that displays customers without a sales order. Primary Key CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table ORDER_DT DATE ORDER_AMT NUMBER (7.customer_id FROM sales_order s). SELECT c.customer_id = s.department_id. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e.department_id = d. Refer to Section 4 41.customer_id.department_id).department_name FROM employees e RIGHT OUTER JOIN departments d ON (e. SELECT e.last_name. sales_order s WHERE c. e. d. Which query will retrieve all the rows in the EMPLOYEES table.department_name FROM employees e NATURAL JOIN departments d. Incorrect.customer_id (+) = s. d.department_id.FROM customers c.last_name.customer_id). e.customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c. . department_id). (*) SELECT e. e. Incorrect. d.department_id).SELECT e.department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_id.department_id = d. d.department_id = d.last_name.department_id. e. 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 .last_name.department_name FROM employees e JOIN departments d USING (e. 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.Incorrect. 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 . Refer to Section 4 43. Refer to Section 4 44. Evaluate this SELECT statement: SELECT MAX(salary). The highest salary in each department. The employee with the highest salary for each department. (*) The employees with the highest salaries. Refer to Section 5 45. dept_id FROM employee GROUP BY dept_id. Which values are displayed? Mark for Review (1) Points The highest salary for all employees. .order by clause group by clause (*) Incorrect. Refer to Section 5 46. Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. . AVG (salary)"Average" FROM employees GROUP BY Department. What is the best explanation as to why this SQL statement will NOT execute? SELECT department_id "Department". (*) Group functions can only be used in a SELECT list. Which statement about group functions is true? Mark for Review (1) Points Group functions ignore null values. Refer to Section 5 47.Incorrect. Incorrect. A query that includes a group function in the SELECT list must include a GROUP BY clause. Group functions can be used in a WHERE clause. (*) The GROUP BY clause must have something to GROUP. The AVG. Refer to Section 5 48. Incorrect. VARIANCE. SUM. 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 .You cannot use a column alias in the GROUP BY clause. The department id is not listed in the departments table. SELECT SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'.86590586 8908090 10-JUN-03 BASIC 859. 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'.00 85490345 5489304 20-MAR-03 BASIC 568. February and March of 2003. (*) SELECT AVG(payment_amount) FROM payment.00 You need to determine the average payment amount made by each customer in January. SELECT AVG(payment_amount) .00 89453485 8549038 15-FEB-03 INTEREST 596. MAR). Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE Incorrect. The VENDORS table contains these columns: VENDOR_ID NUMBER Primary Key NAME VARCHAR2(30) LOCATION_ID NUMBER . Correct 50. FEB. Refer to Section 5 51.FROM payment WHERE TO_CHAR(payment_date) IN (JAN. You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. 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. Which group function would you use to display the lowest value in the SALES_AMOUNT column? Mark for Review (1) Points . MIN(AVG(order_amount)) (*) Incorrect.ORDER_DT DATE ORDER_AMOUNT NUMBER(8. Refer to Section 5 52. AVG COUNT MAX MIN (*) Incorrect. 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 . Refer to Section 5 53. The PRODUCTS table contains these columns: PROD_ID NUMBER(4) PROD_NAME VARCHAR2(30) PROD_CAT VARCHAR2(30) PROD_PRICE NUMBER(3) . 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.54. Which group functions below act on character. (*) Incorrect. 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. prod_qty) FROM products. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 . The values in the PROD_PRICE column and the PROD_QTY column are averaged together.PROD_QTY NUMBER(4) The following statement is issued: SELECT AVG(prod_price. Refer to Section 5 56. An error occurs. Only the average quantity of the products is returned. 00 809090 LOAFER 89098 10.00 857689 HEEL 85940 11. Which value is displayed? Mark for Review (1) Points 0 6 7 (*) The statement will NOT execute successfully. .00 890890 LOAFER 89789 14.968950 SANDAL 85909 10.00 869506 SANDAL 89690 15.00 758960 SANDAL 86979 You issue this SELECT statement: SELECT COUNT(category) FROM styles. SELECT COUNT(*) FROM line_item.25 0. SELECT AVG(discount) FROM line_item. . (*) SELECT SUM(discount) FROM line_item.10 768385 862459 849869 5.05 867950 985490 945809 5.99 0. 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.60 954039 439203 438925 5.60 0.15 543949 349302 453235 4.50 You query the LINE_ITEM table and a value of 5 is returned.Incorrect. Which SQL statement did you execute? Mark for Review (1) Points SELECT COUNT(discount) FROM line_item. Which statement is true? Mark for Review (1) Points . Refer to Section 5 59. Refer to Section 5 58. Evaluate this SELECT statement: SELECT COUNT(*) FROM products. Group functions can avoid computations involving duplicate values by including which keyword? Mark for Review (1) Points NULL DISTINCT (*) SELECT UNLIKE Incorrect.Incorrect. (*) The number of unique PRODUCT_IDs in the table is displayed. 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. Refer to Section 5 60.) Mark for Review (1) Points (Choose all correct answers) ORDER BY AVG(salary) . An error occurs because no WHERE clause is included in the SELECT statement. An error occurs due to an error in the SELECT clause.The number of rows in the table is displayed. Incorrect. GROUP BY MAX(salary) (*) SELECT AVG(NVL(salary. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Incorrect. Refer to Section 6 61. Which SELECT statement should you use? Mark for Review (1) Points SELECT location_id. 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. . Correct 62. What is the correct order of clauses in a SELECT statement? Mark for Review (1) Points SELECT FROM . COUNT(type) FROM manufacturer GROUP BY location_id. COUNT(DISTINCT type) FROM manufacturer. SELECT location_id. COUNT(DISTINCT type) FROM manufacturer GROUP BY type. SELECT location_id.(*) SELECT location_id. WHERE ORDER BY HAVING SELECT FROM HAVING GROUP BY WHERE ORDER BY SELECT FROM WHERE GROUP BY HAVING ORDER BY (*) SELECT FROM WHERE . MIN (prod_price) FROM products GROUP BY prod_price.HAVING ORDER BY GROUP BY Correct 63. . Which statement could you use to accomplish this task? Mark for Review (1) Points SELECT prod_cat. 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. (*) SELECT MIN (prod_price). MIN (prod_cat) FROM products GROUP BY prod_cat. SELECT prod_price. The EMPLOYEES table contains these columns: ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER SALARY NUMBER (7. MIN (prod_price) FROM products GROUP BY prod_cat.2) HIRE_DATE DATE . prod_cat FROM products GROUP BY MIN (prod_price).SELECT prod_cat. Correct 64. prod_cat. Evaluate this SELECT statement: . The WHERE clause contains a syntax error.Evaluate this SQL statement: SELECT id_number. The SALARY column is NOT included in the GROUP BY clause. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. id_number. name. (*) Correct 65. The HIRE_DATE column is NOT included in the GROUP BY clause. department_id. name ORDER BY hire_date. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing. Which clause of the SELECT statement contains a syntax error? Mark for Review (1) Points SELECT FROM WHERE GROUP BY (*) Incorrect. department_name FROM employee WHERE dept_id = 1 GROUP BY department. Refer to Section 66.SELECT SUM(salary). 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 . dept_id. team_id) WHERE UPPER(p.team_name. SELECT t. teams t ON (p. COUNT(p.player_id) FROM players JOIN teams t ON (p.team_name.position) = 'PITCHER' GROUP BY t.player_id) > 5. SELECT t.team_id) . Which SELECT statement will produce the desired result? Mark for Review (1) Points SELECT t.team_name.player_id) FROM players p. teams t ON (p.team_id = t.player_id) FROM players p.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.team_name.team_id = t.position) = 'PITCHER' HAVING COUNT(p. COUNT(p. COUNT(p.team_id) WHERE UPPER(p.team_id = t. WHERE UPPER(p.player_id) > 5.player_id) > 5. 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. (*) Incorrect.position) = 'PITCHER' GROUP BY t. you use should a WHERE clause.team_id) WHERE UPPER(p.team_name.position) = 'PITCHER' GROUP BY t. .player_id) FROM players p JOIN teams t ON (p. You must use the HAVING clause with the GROUP BY clause. rows are not sorted when a GROUP BY clause is used. (*) You can use a column alias in a GROUP BY clause.team_name HAVING COUNT(p. SELECT t.team_name HAVING COUNT(p. By default. COUNT(p.team_id = t. Refer to Section 6 67. 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. 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 (*) . Refer to Section 6 68.Incorrect. (*) Incorrect. 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) .The result of the main query is used with the subquery Correct 70. SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments). SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id). (*) 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). . 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 .Incorrect. 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'. (*) . total FROM ORDERS WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin'. total FROM ORDERS (SELECT emp_id FROM employees WHERE lname = 'Franklin') WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01'. emp_id.(1) Points SELECT order_id. 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. 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.Correct 72.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 all the orders that were placed on a certain date. You need to display each date that a customer placed an order. . (*) Incorrect. . Refer to Section 6 73. However. 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').You need to display all the orders that were placed on the same day as order number 25950. you are not sure which supervisor ID belongs to Brad Carter. SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. what will the outer query return? Mark for Review (1) Points . If a single-row subquery returns a null value and uses the equality comparison operator. (*) Incorrect.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'). Refer to Section 6 74. Which best describes a single-row subquery? Mark for Review (1) Points a query that returns only one row from the inner SELECT statement (*) a query that returns one or more rows from the inner SELECT statement a query that returns only one column value from the inner SELECT statement a query that returns one or more column values from the inner SELECT statement Incorrect. Refer to Section 6 75. Refer to Section 6 .no rows (*) all the rows in the table a null value an error Incorrect. Refer to Section 6 77. .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. 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). What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. (*) Incorrect. . name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. Evaluate this SELECT statement: SELECT customer_id. Refer to Section 6 78.SELECT description FROM d_types WHERE code <> ALL (SELECT type_code FROM d_songs).00). All of the above. No rows would be returned by the outer query.. and ALL (*) LIKE BETWEEN.. <. Refer to Section 6 79. which comparison operator(s) can you use? Mark for Review (1) Points IN.. Refer to Section 6 80. (*) All the rows in the table would be selected.. =. Incorrect. Which of the following best describes the meaning of the ANY operator? Mark for Review . Only the rows with CUSTOMER_ID values equal to null would be selected. You need to create a SELECT statement that contains a multiple-row subquery. ANY.AND. and > Incorrect. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review (1) Points ALL ANY = (*) > .(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. Incorrect. 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. Incorrect. Refer 82. The data returned may or may not be correct. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). Which values will be displayed? . last_name. Refer to Section 6 83. Evaluate this SQL statement: SELECT employee_id. 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 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 = (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: 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) 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 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'); 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) 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 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) 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 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 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. (*) 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: 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) 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 (*) 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. 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. Knowledge (*) Raw Materials Intelligence (*) There is no difference between data and information 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 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 Databases were invented in 1989. True or False? True - False (*) Oracle Database Software do not provide or does not comprise of which functionality? Graphical User Interface - Internet Browser - Server - Operating System (*) An entity is instantiated as a ? experience - instance - table (*) - none of the above 2. Information which was gained from data is the same as: (Choose Two) 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. Relationship names are usually verbs. True or False? True (*) - False The entity/relationship model is created before the physical database design model. True or False? True (*) - False All of the following could be attributes of an ENTITY called PERSON except one. Select the incorrect one: Haircolor - Weight - Gender - Natacha Hansen (*) An entity can have many Unique Identifiers. True or False? True (*) - False Volatile entities have special requirements and need special attention when you are doing data modelling. True or False? True (*) - False 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 Relationship Names are optional. True or False? True - False (*) Which of the following are valid relationship degrees 1:1 (*) 1:M (*) 1:O O:O Which symbol is used to show that a particular attribute is mandatory? * (*) O # & The many end of a Relationship is called: Gulls Foot Pigs Ear Crows Ear Crows Foot (*) 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 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 Which of the following are suitable Entity names? (Choose Two) DOGS 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. ANIMAL (*) ANIMALS DOG (*) 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. All instances of the supertype must be an instance of one of the subtypes. True or False? True (*) False All instances of the subtypes can be an instance of the supertype but do not have to. True or False? True False (*) 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. 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 (*) Business rules are not important to data modelers. True or False? True False (*) 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. A non-transferable relationship means the detail cannot be changed to point to a new master. True or False? True (*) False 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 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 How do you include a relationship as part of the UID for an entity? By barring the relationship in question (*) 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 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. 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 (*) 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. When data is stored in one place in a database, the database conforms to the rules of Normality Reduction Normalization (*) Multiplication 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. No parts of a UID are mandatory. True or False? True - False (*) Which of the following is NOT a relationship type? Some to None (*) - One to One - One to Many - Many to Many All relationships participating in an arc must be mandatory. True or False? True - False (*) 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) Arcs are Mandatory in Data modelling. All ERD's must have at least one Arc. True or False? True - False (*) 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 Modeling historical data can produce a unique identifier that always excludes dates. True or False? - True - False (*) 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. 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 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: 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; 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, leftpadded 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 (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 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; (*) 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) 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 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 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 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 (*) 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 You want the orders with the highest amounts to appear first. SELECT orderid. You want to create a report that displays all orders and their amounts that were placed during the month of January. Which query should you issue? Mark for Review (1) Points 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 IN ( 01-jan-02 . (*) SELECT orderid. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC. 31-jan-02 ) ORDER BY total.14. total . FROM orders WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02' ORDER BY total DESC. (SYSDATE-hire_date)/7 DISPLAY WEEKS FROM employees WHERE department id = 90. SELECT last_name. Incorrect. (SYSDATE-hire_date)/7 AS WEEKS FROM employees WHERE department_id = 90. # of WEEKS FROM employees . Refer to Section 1 15. (*) SELECT last name. 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)AS WEEK FROM employees WHERE department_id = 90. 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 (*) .WHERE department_id = 90. Incorrect. SELECT last_name. Incorrect. Not all date functions return date values.) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. Refer to Section 2 . Which two statements concerning SQL functions are true? (Choose two. Conversion functions convert a value from one data type to another data type.1917 Correct 17. (*) Number functions can return number or character values. (*) Single-row functions manipulate groups of rows to return one result per group of rows. 00. All Human Resources data is stored in a table named EMPLOYEES.000. Each employee's salary must be displayed in the following format: $000. You have been asked to create a report that displays each employee's name and salary.6 .TO_DATE('01-OCT-2004') (*) NEXT_DAY(hire_date) + 5 SYSDATE . Refer to Section 2 19.18. Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . 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. SELECT companyname. 'fmdd. 13 April. You have been asked to create a report that lists all customers who have placed orders of at least $2. dy month. total FROM customers NATURAL JOIN orders WHERE total >= 2500. Tuesday. total FROM customers NATURAL JOIN orders WHERE total >= 2500. TO_DATE (date. dd month. Refer to Section 2 20.500. The report's date should be displayed in the Day. TO_DATE (sysdate.SYSDATE + 30 / 24 Incorrect. 2004 ). yyyy'). Which statement should you issue? Mark for Review (1) Points SELECT companyname. total FROM customers NATURAL JOIN orders WHERE total >= 2500. 'day. SELECT companyname. TO_CHAR (sysdate. dy month. . Date Month. Year format (For example. 'dd. yyyy'). yyyy'). (*) Incorrect.Database Programming with SQL Review your answers. . Refer to Section 2 Page 2 of 10 Test: Mid Term Exam . yyyy'). TO_CHAR (sysdate. and question scores below. feedback.SELECT companyname. An asterisk (*) indicates a correct answer. dd Month. total FROM customers NATURAL JOIN orders WHERE total >= 2500. 'fmDay. Refer to Section 2 Section 2 Lesson 2 . Use the TO_DATE function to convert a character string to a date value. Which three statements concerning explicit data type conversions are true? (Choose three.Section 2 Lesson 1 (Answer all questions in this section) 21. Use the TO_CHAR function to convert a number or date value to character string. (*) Incorrect.) 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 date value to character string or number. (*) Use the TO_NUMBER function to convert a character string of digits to a number. What would happen if the PRICE column contains null values? Mark for Review . Refer to Section 2 23. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. (*) COALESCE. NVL and COALESCE. '0') FROM PRODUCT. NVL.(Answer all questions in this section) 22. can be used with group functions to replace null values.2) Evaluate this statement: SELECT NVL(10 / price. but not NVL and NVL2. NVL2. The PRODUCT table contains this column: PRICE NUMBER(7. and COALESCE can be used with group functions to replace null values. can be used with group functions to replace null values. but not COALESCE. but not NVL2. can be used with group functions to replace null values. Incorrect. The statement would fail because values cannot be divided by null. A value of 0 would be displayed.(1) Points The statement would fail because values cannot be divided by 0. Correct 24. (*) A value of 10 would be displayed. 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 . You need to replace null values in the DEPARTMENT_ID column with the text "N/A". how many join conditions are needed in the WHERE clause? Mark for Review (1) Points 0 1 2 (*) 3 Incorrect.Incorrect. When joining 3 tables in a SELECT statement. Refer to Section 3 . Refer to Section 2 Section 3 Lesson 2 (Answer all questions in this section) 25. employee_id.26. The company president would like the sales listed starting with the highest amount first. e. sales_dept s ORDER BY sales DESC .employee_id. s.first_name.bonus.last_name.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.000. 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. e. 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. s. s.sales FROM employees e. bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC. (*) Incorrect. s. s.employee_id = s. sales_dept s AND s.employee_id = s. s.bonus IS NOT NULL. Refer to Section 3 . e. sales_dept s WHERE e.employee_id = s. e.employee_id.employee_id.employee_id. s.bonus.employee_id AND s.first_name.WHERE e. e.first_name. e.employee_id AND sales > 50000 AND s. SELECT e. sales WHERE e.last_name. sales FROM employees e. s.employee_id. e.employee_id.first_name.employee_id.bonus IS NOT NULL AND sales > 50000. sales_dept s WHERE e. s. s. SELECT e.last_name.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC.bonus.employee_id AND s.last_name. s.employee_id = s.employee_id FROM employees e. SELECT e. s. e. sales ORDER BY sales DESC FROM employees e.bonus. departments d WHERE e.first_name.department_name FROM employees e.department_id > 5000 ORDER BY 4. e. Incorrect.department_name FROM employees e. e.department_id = d.last_name.department_id = d.department_id AND employees. Evaluate this SQL statement: SELECT e.department_id > 5000 (*) ORDER BY 4. d. departments d WHERE e.employee_id.27. e.last_name. Which clause contains a syntax error? Mark for Review (1) Points SELECT e. d.first_name. e.employee_id.department_id AND employees. Refer to Section 3 . 28. doctor_id FROM patients. doctors. 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. 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 . What happens when you create a Cartesian product? Mark for Review (1) Points . 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.A syntax error Incorrect. Refer to Section 3 29. Refer to Section 3 30. An asterisk (*) indicates a correct answer.Database Programming with SQL Review your answers. feedback. 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 . .All rows from one table are joined to all rows of another table (*) The table is joined to itself. and question scores below. one column to the next column. 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.. Using Oracle Proprietary join syntax. Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. The FULL.. RIGHT.. and IN IN and = Correct 32. .Section 3 Lesson 4 (Answer all questions in this section) 31. or LEFT keyword must be included.AND.. (*) Outer joins are always evaluated before other types of joins in the query.The OR operator cannot be used to link outer join conditions. Refer to Section 3 33. Incorrect. 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 . 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. You need to join two tables that have two columns with the same name.Section 4 Lesson 2 (Answer all questions in this section) 34. datatype and precision. 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) . 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.Equijoin (*) Self join (*) Nonequijoin Simple join (*) Full outer join Incorrect. If the columns having the same names have different data types. (*) . If it selects rows from the two tables that have equal values in all matched columns. Refer to Section 4 36. then an error is returned. When the NATURAL JOIN clause is based on all columns in the two tables that have the same name. 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. Below find the structure of the CUSTOMERS and SALES_ORDER tables: . Refer to Section 4 38. CUSTOMERS CUSTOMER_ID NUMBER NOT NULL.2) SALES_ORDER ORDER_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. 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? . customer_id (+) = s.customer_name FROM customers c.customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c.customer_id not in (SELECT s.customer_id(+).Mark for Review (1) Points SELECT c. SELECT c. sales_order s WHERE c.customer_id FROM sales_order s).customer_id.customer_name FROM customers c WHERE c.customer_id = s.customer_id).customer_name FROM customers c.customer_id = s. SELECT c. (*) SELECT c. . sales_order s WHERE c. physician_id) JOIN admission c . 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.admission FROM patient a JOIN physician b ON (b. c. ' || a.first_name as "Physician". Evaluate this SELECT statement: SELECT a. b. Refer to Section 4 40.first_name as "Patient".Incorrect. ' || b.last_name || '.last_name || '.physician_id = c. Refer to Section 4 Page 4 of 10 . Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b.patient_id) Incorrect.ON (a.patient_id).patient_id = c.physician_id) (*) JOIN admission c ON (a.patient_id = c.physician_id = c. SELECT companyname. total FROM customers c LEFT JOIN orders o ON c.Test: Mid Term Exam .cust_id = o. . Section 4 Lesson 4 (Answer all questions in this section) 41.Database Programming with SQL Review your answers.cust_id.cust_id. orderdate.cust_id = o. orderdate. and question scores below. Which query represents the correct syntax for a left outer join? Mark for Review (1) Points SELECT companyname. An asterisk (*) indicates a correct answer. feedback. total FROM customers c OUTER JOIN orders o ON c. cust_id. Incorrect. (*) SELECT companyname. Refer to Section 4 42. total FROM customers c LEFT OUTER JOIN orders o ON c. total FROM customers c LEFT OUTER orders o ON c.cust_id = o. 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 . orderdate. orderdate.cust_id = o.SELECT companyname.cust_id. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Refer to Section 4 Section 5 Lesson 1 . Refer to Section 4 43. 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.OUTER JOIN and USING Incorrect. Evaluate this SELECT statement: . Correct 45. The highest salary in each department. The employee with the highest salary for each department. department_id FROM employees GROUP BY department_id. Which values are displayed? Mark for Review (1) Points The highest salary for all employees. Evaluate this SELECT statement: SELECT MAX(salary).(Answer all questions in this section) 44. (*) The employees with the highest salaries. If a select list contains both columns as well as groups function then what clause is required? Mark for Review (1) Points having clause .SELECT MIN(hire_date). The latest hire date in the EMPLOYEES table. The hire dates in the EMPLOYEES table that contain NULL values. Refer to Section 5 46. Which values are displayed? Mark for Review (1) Points The earliest hire date in each department. department_id FROM employees GROUP BY department_id. Incorrect. (*) The the earliest hire date in the EMPLOYEES table. join clause order by clause group by clause (*) Incorrect. 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. Refer to Section 5 . Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE Incorrect. You need to calculate the standard deviation for the cost of products produced in the Birmingham facility.Section 5 Lesson 2 (Answer all questions in this section) 48. 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'. model FROM trucks WHERE model = '4x4'. Correct 50. Which group function will you use? Mark for Review (1) Points MAX SUM (*) . You need to compute the total salary for all employees in department 10. SELECT AVG(price) FROM trucks WHERE model IS 4x4. (*) SELECT AVG (price) FROM trucks WHERE model IS '4x4'. SELECT AVG(price). Database Programming with SQL Review your answers. Section 5 Lesson 2 (Answer all questions in this section) .VARIANCE COUNT Correct Page 5 of 10 Test: Mid Term Exam . and question scores below. An asterisk (*) indicates a correct answer. feedback. Which aggregate function can be used on a column of the DATE data type? Mark for Review (1) Points AVG MAX (*) STDDEV SUM Incorrect. 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 . Refer to Section 5 52.51. 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. .Correct 53. Only the average quantity of the products is returned. Refer to Section 5 54.The values in the PROD_PRICE column and the PROD_QTY column are averaged together. 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 AVG. (*) Incorrect. SUM. VARIANCE. An error occurs. The CUSTOMERS table contains these columns: CUSTOMER_ID NUMBER(9) . 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.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. Refer to Section 5 Section 5 Lesson 3 . Which group function should you use to calculate this value? Mark for Review (1) Points AVG (*) SUM COUNT STDDEV Incorrect. Evaluate this SELECT statement: SELECT COUNT(*) FROM employees WHERE salary > 30000. (*) The query generates an error and returns no results. The number of rows in the EMPLOYEES table that have a salary greater than 30000. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) .(Answer all questions in this section) 56. The total of the SALARY column for all employees that have a salary greater than 30000. Which results will the query display? Mark for Review (1) Points The number of employees that have a salary less than 30000. Correct 57. 000? Which SELECT would you use? Mark for Review (1) Points SELECT * FROM employees WHERE salary > 50000.2) DEPARTMENT_ID NUMBER(9) You need to display the number of employees whose salary is greater than $50. (*) . SELECT COUNT(*) FROM employees WHERE salary < 50000. SELECT COUNT(*) FROM employees WHERE salary > 50000.LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7. SELECT * FROM employees WHERE salary < 50000. Incorrect. salary. Evaluate this SQL statement: SELECT COUNT (amount) FROM inventory. 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. department_id. last_name. first_name.SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id. The statement will return the total number of rows in the AMOUNT column. What will occur when the statement is issued? Mark for Review (1) Points The statement will return the greatest value in the INVENTORY table. (*) . Refer to Section 5 58. Incorrect. 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 ROWCOUNT FROM products. Refer to Section 5 59. SELECT COUNT FROM products. Incorrect. Refer to Section 5 Section 6 Lesson 1 (Answer all questions in this section) . manager_id FROM employees GROUP BY department_id. department_id. Evaluate this SELECT statement: SELECT SUM(salary). manager_id. 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. Which SELECT statement clause allows you to restrict the rows returned. Refer to Section 6 Page 6 of 10 .60. Database Programming with SQL Review your answers. (*) You can use a column alias in a GROUP BY clause. By default.Test: Mid Term Exam . An asterisk (*) indicates a correct answer. and question scores below. 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 must use the HAVING clause with the GROUP BY clause. rows are not sorted when a GROUP BY clause is used. feedback. you should use a WHERE clause. Section 6 Lesson 1 (Answer all questions in this section) 61. . 2003 ? Mark for Review (1) Points SELECT customer_id. (*) SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. COUNT(payment_id) . 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. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. SELECT customer_id.Correct 62. FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. Refer to Section 6 63. 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 . Evaluate this SELECT statement: SELECT COUNT(emp_id). Incorrect. mgr_id. SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. department_id FROM employees GROUP BY department_id.MGR_ID must be included in the GROUP BY clause. Which clause should you include in the SELECT statement? Mark for Review (1) Points WHERE salary > 15000 (*) . Incorrect. The ORDER BY clause must specify a column name in the EMPLOYEE table. (*) The HAVING clause must specify an aggregate function. Refer to Section 6 64. Evaluate this SELECT statement: SELECT COUNT(employee_id). A single query cannot contain a WHERE clause and a HAVING clause. You only want to include employees who earn more than 15000. ) Mark for Review (1) Points (Choose all correct answers) ORDER BY AVG(salary) (*) .HAVING salary > 15000 WHERE SUM(salary) > 15000 HAVING SUM(salary) > 15000 Incorrect.2) Which two clauses represent valid uses of aggregate functions? (Choose three. 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. id_number. 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. name . department_id. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id.2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Incorrect. hire_date. name.GROUP BY MAX(salary) SELECT AVG(NVL(salary. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. The HIRE_DATE column is NOT included in the GROUP BY clause. . The WHERE clause contains a syntax error. Refer to Section 6 67.ORDER BY hire_date. Evaluate this statement: SELECT department_id. (*) Incorrect. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. The SALARY column is NOT included in the GROUP BY clause. AVG(salary) WHERE job_id <> 69879 (*) GROUP BY job_id. Mark for Review (1) Points (Choose all correct answers) SELECT department_id. Which statement about subqueries is true? Mark for Review .Which clauses restricts the result? Choose two. department_id HAVING AVG(salary) > 35000 (*) Correct Section 6 Lesson 2 (Answer all questions in this section) 68. Refer to Section 6 69.(1) Points Subqueries should be enclosed in double quotation marks. after the main or outer query executes. (*) Subqueries generally execute last. Incorrect. Subqueries are often used in a WHERE clause to return values for an unknown conditional value. Which operator can be used with a multiple-row subquery? Mark for Review (1) Points IN (*) <> = LIKE . Subqueries cannot contain group functions. Refer to Section 6 70.Incorrect.) Mark for Review (1) Points (Choose all correct answers) SELECT * FROM class_assignments . Which two SQL statements correctly use subqueries? (Choose two. 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. WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments). . (*) 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 teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963). SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id). feedback. An asterisk (*) indicates a correct answer. Section 6 Lesson 2 (Answer all questions in this section) 71. Refer to Section 6 Page 7 of 10 Test: Mid Term Exam . and question scores below. Using a subquery in which of the following clauses will return a syntax error? Mark for Review (1) Points WHERE .Incorrect.Database Programming with SQL Review your answers. You need to create a report to display the names of products with a cost value greater than the average cost of all products.FROM HAVING You can use subqueries in all of the above clauses. (*) Correct 72. 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). product_name FROM products WHERE cost > AVG(cost) GROUP by product_name.SELECT AVG(cost). what will the outer query return? Mark for Review (1) Points no rows (*) . 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. SELECT product_name FROM (SELECT AVG(cost) FROM product) WHERE cost > AVG(cost). 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) . Examine the structure of the EMPLOYEE. and ORDERS tables. Refer to Section 6 74.all the rows in the table a null value an error Incorrect. DEPARTMENT. Which statement about the <> operator is true? Mark for Review (1) Points The <> operator is NOT a valid SQL operator. 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. .DATE DATE CUSTOMER_ID NUMBER(9) You want to display all employees who had an order after the Sales department was established. Refer to Section 6 75. The <> operator CANNOT be used in a single-row subquery. Which values will be displayed? Mark for Review (1) Points . (*) Incorrect.The <> operator returns the same result as the ANY operator in a subquery. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). Evaluate this SQL statement: SELECT employee_id. last_name. The <> operator can be used when a single-row subquery returns only one row. Refer to Section 6 Section 6 Lesson 4 (Answer all questions in this section) 76. 000 and more than $50. All employees who work in a department with employees who earn more than $30.000.000.000. but less than $50.000. Only employees who earn less than $50. (*) Correct 77. All employees who work in a department with employees who earn more than $30.Only employees who earn more than $30.2) DEPART_HIST: EMPLOYEE_ID NUMBER(9) .000. 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. department_id) IN (SELECT employee_id.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. first_name. last_name. last_name. department_id FROM employee WHERE (employee_id. (*) SELECT employee_id. first_name. . Which query should you use? Mark for Review (1) Points SELECT employee_id. new_dept_id FROM depart_hist WHERE old_dept_id = 15) AND new_dept_id = 10. department_id FROM employee WHERE (employee_id) IN (SELECT employee_id FROM employee_hist WHERE old_dept_id = 15). but used to be in department 15. department_id) = (SELECT employee_id. first_name. SELECT employee_id. department_id FROM employee WHERE (employee_id. last_name.SELECT employee_id. first_name. 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 . department_id) IN (SELECT employee_id. new_dept_id FROM depart_hist WHERE new_dept_id = 15). department_id FROM employee WHERE (employee_id. last_name. dept_id FROM employee WHERE old_dept_id = 15). Incorrect. All of the above. Evaluate this SELECT statement: SELECT customer_id. Refer to Section 6 79. SELECT description FROM d_types WHERE code <> ALL (SELECT type_code FROM d_songs). (*) Incorrect. name FROM customer WHERE customer_id IN (SELECT customer_id .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). Only the rows with CUSTOMER_ID values equal to null would be selected. No rows would be returned by the outer query.00). 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. Incorrect. Refer to Section 6 80. What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. . (*) Single-row operators can be used with both single-row and multiple-row subqueries.FROM customer WHERE state_id = 'GA' AND credit_limit > 500. (*) All the rows in the table would be selected. feedback. Multiple-row subqueries can only be used in SELECT statements. Correct Page 8 of 10 Test: Mid Term Exam . and question scores below.Multiple-row subqueries can be used with both single-row and multiple-row operators. Section 6 Lesson 4 (Answer all questions in this section) .Database Programming with SQL Review your answers. An asterisk (*) indicates a correct answer. 81. What would happen if the inner query returned a NULL value row? . last_name. first_name FROM student WHERE major_id NOT IN (SELECT major_id FROM majors WHERE department_head_id = 30 AND title = 'ADJUNCT'). Evaluate this SELECT statement: SELECT student_id. 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. 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 . No rows would be returned from the STUDENT table. last_name. (*) All the rows in the STUDENT table would be displayed. Which of the following is a valid reason why the query below will not execute successfully? SELECT employee_id. Only the rows with STUDENT_ID values equal to NULL would be displayed.Mark for Review (1) Points A syntax error would be returned. Correct 83. . The greater than operator is not valid. Incorrect. Evaluate this SELECT statement that includes a subquery: SELECT last_name. Which statement is true about the given subquery? Mark for Review (1) Points The outer query executes before the nested subquery. (*) Second subquery found on the right instead of the left side of the operator. first_name FROM customer WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). (*) An error occurs if the either the inner or outer queries do not return a value. The results of the inner query are returned to the outer query. Refer to Section 6 84.Single rather than multiple value operator used. . Incorrect. Refer to Section 6 85. What is wrong with the following query? SELECT employee_id. Mark for Review (1) Points Single rows contain multiple values and a logical operator is used. last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). Nothing.Both the inner and outer queries must return a value. Subquery returns more than one row and single row comparison operator is used. or an error occurs. (*) Subquery references the wrong table in the WHERE clause. it will run without problems. job ID from departments for Executive employees. The department ID.Incorrect. You are looking for Executive information using a subquery. (*) Correct . The department ID. job ID for every employee in the Executive department. job_id FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE department_name = 'Executive'). last_name. The department ID. last name. What will the following SQL statement display? SELECT department_id. last name. department name for every Executive in the employees table. Mark for Review (1) Points The department ID. Refer to Section 6 86. department name and last name for every employee in the Executive department. last name. first_name. 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. enroll_date FROM students WHERE UPPER(stu_type_id) = 'F'). dob.You want to insert all fulltime students. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id. stu_type_id. with an identical structure. last_name. into the new table. named FT_STUDENTS.Section 7 Lesson 1 (Answer all questions in this section) 87. What is the result of executing this INSERT statement? Mark for Review (1) Points . who have a STU_TYPE_ID value of "F". An error occurs because you CANNOT use a subquery in an INSERT statement. You need to add a row to an existing table. (*) An error occurs because the FT_STUDENTS table already exists. Which DML statement should you use? Mark for Review (1) Points UPDATE INSERT (*) DELETE CREATE . Incorrect. Refer to Section 7 88. An error occurs because the INSERT statement does NOT contain a VALUES clause.All full-time students are inserted into the FT_STUDENTS table. 'samerica'). 'tflanders'. company.Correct 89. (*) . poc. 'samerica'). 'tflanders'. Because the new customer has not had a credit check. You have been instructed to add a new customer to the CUSTOMERS table. 'InterCargo'. you should not add an amount to the CREDIT column. 'InterCargo'. 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. null. location) VALUES (200. (*) INSERT INTO customers VALUES (200. 'Public Relations'. Assume all the column names are correct. Incorrect.INSERT INTO customers VALUES (cust_id. samerica). tflanders. The following SQL statement will execute which of the following? INSERT INTO departments (department_id. 'InterCargo'. manager_id. InterCargo. 0. Mark for Review (1) Points 100 will be inserted into the department_id column 1700 will be inserted into the manager_id column . 100. poc. credit. department_name. company. location) (200. 'tflanders'. 1700). 0. Refer to Section 7 90. INSERT INTO customers VALUES (200. location_id) VALUES (70. 'samerica'). 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 . feedback. Section 7 Lesson 2 (Answer all questions in this section) . An asterisk (*) indicates a correct answer.Database Programming with SQL Review your answers. and question scores below. 91. Janet is the only person with the last name of Roper that is employed by the company. Her new last name is Cooper. Janet Roper. 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'. One of the sales representatives. has informed you that she was recently married. (*) UPDATE employees last_name = 'cooper' WHERE last_name = 'roper'. and she has requested that you update her name in the employee database. UPDATE employees SET last_name = 'roper' . 2) SALARY NUMBER(9. UPDATE employees SET cooper = 'last_name' WHERE last_name = 'roper'. Correct 92. MANAGERS.WHERE last_name = 'cooper'. Examine the structures of the PLAYERS.2) MANAGERS MANAGER_ID NUMBER Primary Key LAST_NAME VARCHAR2 (20) . 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. their manager. and their team name for all teams with a id value greater than 5000 Incorrect.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. Refer to Section 7 . INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. Her employee ID is still 189. MERGE (*) INSERT.93. Refer to Section 7 94. Which two commands can be used to create new rows? Mark for Review (1) Points INSERT. CREATE INSERT. UPDATE Incorrect. her last name is now Rockefeller. CREATE MERGE. 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. . UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. however. You want to enter a new record into the CUSTOMERS table. One of your employees was recently married. Refer to Section 7 95. Refer to Section 7 96. Which statement is true? Mark for Review (1) Points The statement deletes all the rows from the CUSTOMER table. Incorrect. (*) The statement deletes the CUSTOMER column. Evaluate this statement: DELETE FROM customer. (*) Incorrect. Which two commands can be used to modify existing data in a database row? Mark for Review (1) Points (Choose all correct answers) .UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. The statement deletes the first row in the CUSTOMERS table. The statement removes the structure of the CUSTOMER table from the database. Examine the structures of the PRODUCTS and SUPPLIERS tables: SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. Primary Key PRODUCT_NAME VARCHAR2 (25) . 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.DELETE MERGE (*) SELECT UPDATE (*) Incorrect. Refer to Section 7 97. SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table CATEGORY_ID NUMBER QTY_PER_UNIT NUMBER UNIT_PRICE NUMBER (7. (*) DELETE FROM products WHERE UPPER(city) = '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 .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. When the WHERE clause is missing in a DELETE statement. Correct 98. (*) The table is removed from the database. DELETE FROM products WHERE supplier_id < (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA'). what is the result? Mark for Review (1) Points All rows are deleted from the table. An error message is displayed indicating incorrect syntax.WHERE supplier_id = (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA'). . 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 .Nothing. 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. Incorrect. The statement will not execute. The TEAM_ID value for the Tiger team is 5960.2) You need to increase the salary of each player for all players on the Tiger team by 12. . You need to create a report to display the teachers who were hired more than five years ago.125. (*) Incorrect. 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. Which statement should you use? Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1. You need to display the names of the teachers who teach classes that start within the next week.5 percent. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. Refer to Section 7 100.You need to display the start date for each class taught by a given teacher. UPDATE players SET salary = salary * 1. (*) UPDATE players (salary) VALUES(salary * 1. Refer to Section 7 Page 10 of 10 1.125) WHERE team_id = 5960.UPDATE players SET salary = salary * .125 WHERE team_id = 5960. 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 (*) .125 WHERE team_id = 5960. Incorrect. ) Mark for Review (1) Points (Choose all correct answers) The SYSDATE function returns the Oracle Server date and time. The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length. (*) 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. (*) Correct You query the database with this SQL statement: . not on numbers. Which three statements about functions are true? (Choose three.Correct 2. CONCAT. 1. SUBSTR.00 . LOWER (*) Correct 4.00 968950 SANDAL 85909 10. LOWER CONCAT. In which order are the functions evaluated? Mark for Review (1) Points LOWER. first_name)). The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. SUBSTR. SUBSTR SUBSTR. 5) "ID" FROM employee. CONCAT.SELECT LOWER(SUBSTR(CONCAT(last_name. CONCAT LOWER. -2. SELECT INSTR(category.869506 SANDAL 89690 15.2) FROM styles WHERE style_id = 895840. SELECT SUBSTR(category. (*) .00 857689 HEEL 85940 11.00 You query the database and return the value 40.00 890890 LOAFER 89789 14. 2.2) FROM styles WHERE style_id = 895840.00 809090 LOAFER 89098 10. Which script did you use? Mark for Review (1) Points SELECT INSTR(category.00 758960 SANDAL 86979 11. 2.2) FROM styles WHERE style_id = 895840. 'al') FROM dual. Correct You issue this SQL statement: SELECT INSTR ('organizational sales'.SELECT SUBSTR(category. Which value is returned by this command? Mark for Review (1) Points 1 2 13 (*) .2) FROM styles WHERE style_id = 758960. -2. 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. You need to display the number of characters in each customer's last name. '$')SALARY FROM employees. . LPAD(salary. 15.17 Correct 6. leftpadded with the $ and the column labeled SALARY. size of 15 and the column labeled SALARY. You issue this SQL statement: SELECT ROUND (1282. 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. What value does this statement produce? Mark for Review .Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value." Correct .248. (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. -2) FROM dual. 2) Which value is returned? Mark for Review (1) Points 1 (*) 2 25 0 . Evaluate this function: MOD (25.(1) Points 1200 1282 1282.25 1300 (*) Correct 9. Which function would you use to return the current database server date and time? Mark for Review (1) Points DATE SYSDATE (*) DATETIME .IN. Refer to Section 1 Lesson 1 11.. Which comparison operator retrieves a list of values? Mark for Review (1) Points IN (*) LIKE BETWEEN...Correct 10. IS NULL Incorrect.. You need to subtract three months from the current date. Which function should you use? Mark for Review (1) Points ROUND .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. Evaluate this SELECT statement: . 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.TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN Incorrect. Which SQL Statement should you use to display the prices in this format: "$00. 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. (*) .900.30"? Mark for Review (1) Points SELECT TO_CHAR(price.99') FROM product.SELECT SYSDATE + 30 FROM dual. Refer to Section 1 16. '$99. Incorrect. 000. SELECT TO_NUMBER(price.900. Each employee's salary must be displayed in the following format: $000.00.99") FROM product.99') FROM product.SELECT TO_CHAR(price.99') FROM product. Refer to Section 2 18. '$99.900. The EMPLOYEES table contains these columns: . All Human Resources data is stored in a table named EMPLOYEES. "$99. 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. SELECT TO_CHAR(price. '$99.990. Correct 17. You have been asked to create a report that displays each employee's name and salary. (*) . Month DD. SELECT TO_CHAR(hire_date.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. YYYY) FROM employees. 'Month DD. YYYY') FROM employees. Not all date functions return date values. ' YYYY') FROM employees. (*) Single-row functions manipulate groups of rows to return one result per group of rows. Incorrect. Conversion functions convert a value from one data type to another data type. 'Month DD'. SELECT TO_CHAR(hire_date. (*) Number functions can return number or character values.SELECT hire_date(TO_CHAR 'Month DD'. .) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. ' YYYY') FROM employees. Refer to Section 2 19. Which two statements concerning SQL functions are true? (Choose two. '$999.000. . Which script should you use to display the salaries in format: "$45.00"? Mark for Review (1) Points SELECT TO_CHAR(salary.999') FROM employees.Incorrect.99') FROM employees. 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. '$999. SELECT TO_NUM(salary.990. 00') FROM employees.999. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 Correct . Refer to Section 2 21.SELECT TO_NUM(salary. (*) Incorrect.999. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001. '$999.00') FROM employees. '$999. SELECT TO_CHAR(salary. (*) SELECT NVL(tuition_balance. 0) "Balance Due" FROM student_accounts. When executed. 0). 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. NVL (housing_balance). 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.22. tuition_balance + housing_balance "Balance Due" . (*) COALESCE. but not COALESCE. NVL2. Incorrect. but not NVL and NVL2. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. and COALESCE can be used with group functions to replace null values. NVL and COALESCE. tutition_balance + housing_balance "Balance Due" FROM student_accounts. but not NVL2. can be used with group functions to replace null values. SELECT tuition_balance + housing_balance FROM student_accounts. SELECT TO_NUMBER(tuition_balance. 0). TO_NUMBER (housing_balance.FROM student_accounts. 0). can be used with group functions to replace null values. can be used with group functions to replace null values. Refer to Section 2 24. NVL. . When joining 3 tables in a SELECT statement.000 per year. how many join conditions are needed in the WHERE clause? Mark for Review (1) Points 0 1 2 (*) 3 Correct 26.Correct 25. salary FROM employees WHERE salary > 25000 AND dept_id = 10. Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT last_name. You need to create a report that lists all employees in the Sales department who do not earn $25. . first_name. salary FROM employees WHERE salary = 25000 AND dept_id = 10. The CUSTOMERS and SALES tables contain these columns: CUSTOMERS CUST_ID NUMBER(10) PRIMARY KEY COMPANY VARCHAR2(30) . SELECT last_name. salary FROM employees WHERE salary <= 25000 AND dept_id = 10. first_name. first_name.SELECT last_name. (*) Correct 27. first_name. SELECT last_name. salary FROM employees WHERE salary != 25000 AND dept_id = 10. s. sales s WHERE c.cust_id.cust_id. total_sales FROM customers.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.company. SELECT c. c.cust_id = s.cust_id (+).total_sales FROM customers c. .cust_id.company. sales WHERE cust_id = cust_id. sales s WHERE c. SELECT cust_id.total_sales FROM customers c. c.cust_id = s. company. s. the company and the total sales? Mark for Review (1) Points SELECT c. total_sales FROM customers c.lname. company.emp_id AND revenue >= 100000. SELECT e.cust_id.emp_id = s.fname.emp_id = s.(*) SELECT cust_id. Which query should you issue? Mark for Review (1) Points SELECT e. sales s WHERE c. s.fname.lname. You want to identify the sales representatives who have generated at least $100.sales FROM employees e.emp_id AND revenue > 100000. e.000 in revenue. e. s. sales s WHERE e. (*) .cust_id = s. Correct 28.sales FROM employees e. sales s WHERE e. Your have two tables named EMPLOYEES and SALES. lname. lname.emp_id = s. sales Q FROM employees e. sales s WHERE e.SELECT e.emp_id AND revenue >= 100000.sales FROM employees. SELECT fname. exhausting all possibilities The table is joined to another equal table All rows that do not match in the WHERE clause are displayed . one column to the next column. 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. e.emp_id = s.fname. Correct 29.emp_id AND revenue > 100000. s. sales WHERE e. The FROM clause represents the join criteria. The OR operator cannot be used to link outer join conditions. RIGHT. Refer to Section 3 31. Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. (*) . The WHERE clause represents the join criteria. The FULL. Refer to Section 30. or LEFT keyword must be included. The JOIN keyword must be included.Incorrect. Which statement about the join syntax of a SELECT statement is true? Mark for Review (1) Points The ON keyword must be included. (*) Incorrect. m. m. t.first_name.player_id.manager_id = m. 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 . Evaluate this SELECT statement: SELECT p. Correct 32.team_id = t.team_id).Outer joins are always evaluated before other types of joins in the query.team_name FROM player p LEFT OUTER JOIN player m ON (p.last_name.player_id) LEFT OUTER JOIN team t ON (p. Refer to Section 3 34.. .Correct 33.. Columns with the same names must have the same precision and datatype.AND.. 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.. (*) Columns with the same names must have compatible data types. Which statement about a natural join is true? Mark for Review (1) Points Columns with the same names must have identical data types. and IN IN and = Incorrect. 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. datatypes and lengths (*) A join that produces a Cartesian product . Incorrect. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table. Refer to Section 4 36.Columns with the same names cannot be included in the SELECT list of the query. 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. Which of the following statements is the simplest description of a nonequijoin? Mark for Review (1) Points .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. phone varchar2(20). city varchar2(20). You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in sequence: CREATE TABLE customers (custid varchar2(5). companyname varchar2(30). A join that joins a table to itself Incorrect. A join condition that includes the (+) on the left hand side. . address varchar2(30). Refer to Section 4 39. CREATE TABLE orders (orderid varchar2(5) constraint pk_orders_01 primary key.A join condition containing something other than an equality operator (*) A join condition that is not equal to other joins. contactname varchar2(30). constraint pk_customers_01 primary key (custid)). state varchar2(30). custid varchar2(5) references customers (custid)). (*) . total FROM orders o JOIN customers c ON o. SELECT orderid. Which query should you issue to achieve the desired results? Mark for Review (1) Points SELECT custid. total number(15).custid WHERE city = 'Nashville'. orderdate.custid = c. You have been instructed to compile a report to present the information about orders placed by customers who reside in Nashville .custid = c. companyname FROM customers WHERE city = 'Nashville'. SELECT orderid.custid WHERE city = 'Nashville'. orderdate.orderdate date. total FROM orders o NATURAL JOIN customers c ON o. SELECT orderid.2) . Below find the structure of the CUSTOMERS and SALES_ORDER tables: CUSTOMERS CUSTOMER_ID NUMBER NOT NULL. Correct 40. orderdate. 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. total FROM orders WHERE city = 'Nashville'. SALES_ORDER ORDER_ID NUMBER NOT NULL. (*) SELECT c.customer_name . sales_order s WHERE c.2) SHIP_METHOD VARCHAR2 (5) You need to create a report that displays customers without a sales order.customer_name FROM customers c.customer_id FROM sales_order s). Primary Key CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table ORDER_DT DATE ORDER_AMT NUMBER (7. SELECT c.customer_id = s. 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(+). department_name FROM employees e RIGHT OUTER JOIN departments d ON (e.department_id. e.customer_id).department_id = d.customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c.department_id). e. Incorrect. . even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e.last_name.department_name FROM employees e NATURAL JOIN departments d.department_id. d. d.customer_id (+) = s. SELECT e.customer_id. Refer to Section 4 41.FROM customers c.customer_id = s. Which query will retrieve all the rows in the EMPLOYEES table.last_name. sales_order s WHERE c. SELECT c. department_id.department_id). 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 . e.department_name FROM employees e JOIN departments d USING (e. Incorrect. (*) SELECT e.last_name.department_id = d. d.department_name FROM employees e LEFT OUTER JOIN departments d ON (e. Refer to Section 4 42.SELECT e.department_id = d.department_id.last_name. e. d.department_id). 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 . Refer to Section 4 43. Refer to Section 4 44.Incorrect. 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. Which values are displayed? Mark for Review (1) Points The highest salary for all employees. The employee with the highest salary for each department. .order by clause group by clause (*) Incorrect. (*) The employees with the highest salaries. Refer to Section 5 45. Evaluate this SELECT statement: SELECT MAX(salary). dept_id FROM employee GROUP BY dept_id. The highest salary in each department. . Incorrect. Refer to Section 5 46. A query that includes a group function in the SELECT list must include a GROUP BY clause. Refer to Section 5 47. Which statement about group functions is true? Mark for Review (1) Points Group functions ignore null values.Incorrect. What is the best explanation as to why this SQL statement will NOT execute? SELECT department_id "Department". Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. Group functions can be used in a WHERE clause. (*) Group functions can only be used in a SELECT list. AVG (salary)"Average" FROM employees GROUP BY Department. Incorrect. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT . The department id is not listed in the departments table. 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. (*) The GROUP BY clause must have something to GROUP. Refer to Section 5 48. The AVG. SUM. VARIANCE.You cannot use a column alias in the GROUP BY clause. February and March of 2003. SELECT AVG(payment_amount) . (*) SELECT AVG(payment_amount) FROM payment.00 85490345 5489304 20-MAR-03 BASIC 568. 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 SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'.86590586 8908090 10-JUN-03 BASIC 859.00 You need to determine the average payment amount made by each customer in January.00 89453485 8549038 15-FEB-03 INTEREST 596. MAR). Refer to Section 5 51. FEB.FROM payment WHERE TO_CHAR(payment_date) IN (JAN. Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE Incorrect. The VENDORS table contains these columns: VENDOR_ID NUMBER Primary Key NAME VARCHAR2(30) LOCATION_ID NUMBER . You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. Correct 50. 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. Which group function would you use to display the lowest value in the SALES_AMOUNT column? Mark for Review (1) Points . MIN(AVG(order_amount)) (*) Incorrect.ORDER_DT DATE ORDER_AMOUNT NUMBER(8. Refer to Section 5 52. 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 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) 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 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. 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; 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 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) 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; (*) 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 WHERE ORDER BY HAVING SELECT FROM HAVING GROUP BY WHERE ORDER BY 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) 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; 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 (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 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 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; (*) 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 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) 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 * 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) 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'; 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 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 * FROM employees WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'); SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'); SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id FROM supervisors WHERE last_name = 'Carter'); SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter'); (*) Incorrect. Refer to Section 6 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 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 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 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 (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 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. 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. (*) 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'. (*) 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. 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 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 (*) '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) 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 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'; (*) 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 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) 2) SALARY NUMBER(9.FIRST_NAME VARCHAR2 (25) TEAM_ID NUMBER MGR_ID NUMBER SIGNING_BONUS 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 . all employees in department 10 have the same salary value.To display the names of the managers for all the teams owned by a given owner (*) To display each player. and their team name for all teams with a id value greater than 5000 Correct 94. Which statement should you execute? Mark for Review (1) Points UPDATE employee SET salary = SELECT salary FROM employee . 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. Currently. their manager.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. UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898). Incorrect. UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898) WHERE dept = 10. Which statement is true? Mark for Review (1) Points The statement deletes all the rows from the CUSTOMER table. (*) UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10). (*) .WHERE emp_id = 89898. Evaluate this statement: DELETE FROM customer. Refer to Section 7 95. Incorrect. The PLAYERS table contains these columns: . When the WHERE clause is missing in a DELETE statement. (*) The table is removed from the database.The statement deletes the CUSTOMER column. what is the result? Mark for Review (1) Points All rows are deleted from the table. Refer to Section 7 96. The statement will not execute. Nothing. An error message is displayed indicating incorrect syntax. The statement deletes the first row in the CUSTOMERS table. The statement removes the structure of the CUSTOMER table from the database. Correct 97. Correct 98. You need to delete a record in the EMPLOYEES table for Tim Jones. whose unique employee identification number is 348. The TEAM_ID value for the Tiger team is 5960. UPDATE players SET salary = salary * 1.125.2) You need to increase the salary of each player for all players on the Tiger team by 12. The EMPLOYEES table contains these columns: ID_NUM NUMBER(5) PRIMARY KEY LNAME VARCHAR2(20) . Which statement should you use? Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1.125 WHERE team_id = 5960.125 WHERE team_id = 5960. (*) UPDATE players (salary) VALUES(salary * 1. UPDATE players SET salary = salary * .PLAYER_ID NUMBER NOT NULL PLAYER_LNAME VARCHAR2(20) NOT NULL PLAYER_FNAME VARCHAR2(10) NOT NULL TEAM_ID NUMBER SALARY NUMBER(9.125) WHERE team_id = 5960.5 percent. DELETE 'jones' FROM employees.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 id_num = 348. (*) DELETE FROM employees WHERE lname = jones. In which clause of the UPDATE statement will you specify this condition? Mark for Review (1) Points the ON clause the WHERE clause (*) . You need to update the expiration date of products manufactured before June 30th . Correct 99. 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.the SET clause the USING clause Correct 100. Which function should you use? Mark for Review (1) Points . Which character function should you use? Mark for Review (1) Points INSTR TRUNC SUBSTR (*) CONCAT 3.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. Evaluate this SELECT statement: . 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. 4. What will this SELECT statement display? Mark for Review (1) Points The longest e-mail address in the EMPLOYEE table.SELECT LENGTH(email) FROM employee. Which function should you use? Mark for Review (1) Points LENGTH (*) . You need to display the number of characters in each customer's last name. (*) The maximum number of characters allowed in the EMAIL column. RPAD. Which functions can be used to manipulate character. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. and INITCAP ROUND. LOWER. 1. number. and MOD ROUND.LPAD COUNT SUBSTR 5. TRUNC. and TRIM (*) UPPER. . first_name)). TRUNC. and ADD_MONTH 6. and date column values? Mark for Review (1) Points CONCAT. 5) "ID" FROM employee. SUBSTR. CONCAT. CONCAT LOWER. Which three statements about functions are true? (Choose three. LOWER (*) 7. SUBSTR SUBSTR. CONCAT. SUBSTR. (*) . LOWER CONCAT.In which order are the functions evaluated? Mark for Review (1) Points LOWER.) 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.IN. (*) The CONCAT function can only be used on character strings. IS NULL The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length..... Which comparison operator retrieves a list of values? (1) Points Mark for Review IN (*) LIKE BETWEEN. not on numbers. 10. Evaluate this SELECT statement: SELECT SYSDATE + 30 FROM dual. but NOT character column values? (Choose two. Which value is returned by the query? .) Mark for Review (1) Points (Choose all correct answers) RPAD TRUNC (*) ROUND (*) INSTR CONCAT 11. Which two functions can be used to manipulate number or date column values. 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 . 12.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. YEAR (*) 13. 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 . You need to display the number of months between today's date and each employee's hiredate. # of WEEKS FROM employees WHERE department_id = 90. SELECT last_name. (*) SELECT last name. Which statement concerning single row functions is true? Mark for Review . SELECT last_name. 16.SELECT last_name. (SYSDATE-hire_date)/7 AS WEEKS FROM employees WHERE department_id = 90. (SYSDATE-hire_date)AS WEEK FROM employees WHERE department_id = 90. (SYSDATE-hire_date)/7 DISPLAY WEEKS FROM employees WHERE department id = 90. but can return multiple values.) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. Single row functions can be nested. (*) Single row functions return one or more results per row. Not all date functions return date values. Which two statements concerning SQL functions are true? (Choose two. 17. Single row functions cannot modify a data type. (*) .(1) Points Single row functions can accept only one argument. 18. Which three statements concerning explicit data type conversions are true? (Choose three. (*) Use the TO_DATE function to convert a date value to character string or number.) Mark for Review (1) Points (Choose all correct answers) Use the TO_NUMBER function to convert a number to a character string. (*) Single-row functions manipulate groups of rows to return one result per group of rows. 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.Number functions can return number or character values. Conversion functions convert a value from one data type to another data type. Month DD.Use the TO_CHAR function to convert a number or date value to character string. YYYY') . 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. SELECT TO_CHAR(hire_date. 2000 Which SELECT statement could you use? Mark for Review (1) Points SELECT TO_CHAR(hire_date. 'Month DD. (*) 19. YYYY) FROM employees. 'Month DD'. Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . 20. SELECT TO_CHAR(hire_date. (*) SELECT hire_date(TO_CHAR 'Month DD'.FROM employees. ' YYYY') FROM employees.6 .TO_DATE('01-OCT-2004') (*) NEXT_DAY(hire_date) + 5 SYSDATE . ' YYYY') FROM employees. 2) Evaluate this statement: .SYSDATE + 30 / 24 21. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 Incorrect Incorrect. Refer to Section 2 Previous 22. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001. Page 21 of 100 Next Summary The PRODUCT table contains this column: PRICE NUMBER(7. A value of 0 would be displayed. 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 10 would be displayed. The statement would fail because values cannot be divided by null.SELECT NVL(10 / price. '0') FROM PRODUCT. 23. Which of the following General Functions will return the first non-null expression in the expression list? Mark for Review (1) Points NVL . 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 (*) .NVL2 NULLIF COALESCE (*) 24. You need to replace null values in the DEPT_ID column with the text "N/A". exhausting all possibilities The table is joined to another equal table All rows that do not match in the WHERE clause are displayed Incorrect 26. one column to the next column. Refer to Section 3 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) .The table is joined to itself. Incorrect. 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. doctor_id FROM patients.You issue this statement: SELECT patient_id. how many join conditions are needed in the WHERE clause? Mark for Review (1) Points . When joining 3 tables in a SELECT statement. doctors. 000.0 1 2 (*) 3 Incorrect Incorrect. 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) . 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. Refer to Section 3 28. The company president would like the sales listed starting with the highest amount first. sales FROM employees e.fname.bonus. . sales_dept s ORDER BY sales DESC WHERE e. s. s.emp_id = s.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.lname. e.emp_id. sales ORDER BY sales DESC FROM employees e.bonus IS NOT NULL AND sales > 50000.emp_id AND s.bonus.lname. e. sales_dept s WHERE e. s. SELECT e. s. s.bonus IS NOT NULL. e.emp_id AND sales > 50000 AND s. s.emp_id.emp_id.fname. e.emp_id = s.emp_id. first_name.emp_id = s.emp_id = s.emp_id.000 per year. e.fname.emp_id.lname.emp_id. e. sales_dept s WHERE e. Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT last_name. e. s. (*) 29. You need to create a report that lists all employees in the Sales department who do not earn $25.SELECT e. sales FROM employees e.emp_id FROM employees e. . e.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC.emp_id. s. sales_dept s AND s. sales WHERE e.bonus. salary FROM employees WHERE salary > 25000 AND dept_id = 10. s.emp_id AND s.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC.lname.bonus. s. SELECT e.fname. s. s. salary FROM employees WHERE salary != 25000 AND dept_id = 10. salary FROM employees WHERE salary = 25000 AND dept_id = 10. salary FROM employees WHERE salary <= 25000 AND dept_id = 10. (*) 30. first_name.SELECT last_name. The CUSTOMERS and SALES tables contain these columns: CUSTOMERS CUST_ID NUMBER(10) PRIMARY KEY COMPANY VARCHAR2(30) LOCATION VARCHAR2(20) SALES . SELECT last_name. first_name. first_name. SELECT last_name. cust_id = s.company. sales WHERE cust_id = cust_id.cust_id. company. s. SELECT cust_id. c.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 = s. c. sales s WHERE c. .total_sales FROM customers c. SELECT c. total_sales FROM customers.total_sales FROM customers c. s.cust_id (+). sales s WHERE c.cust_id.company.cust_id. company. The EMPLOYEE_ID column in the ORDER table contains null values for rows that you need to display. The EMPLOYEE_ID column in the EMPLOYEE table corresponds to the EMPLOYEE_ID column of the ORDER table.(*) SELECT cust_id. sales s WHERE c.cust_id.cust_id = s. total_sales FROM customers c. 31. 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 . for Review (1) Points Which of the following best describes the function of an outer join? Mark An outer join will return only those rows that do not meet the join criteria. An outer join will return data only if both tables contain an identical pair of columns. RIGHT. An outer join will return only data from the far left column in one table and the far right column in the other table. . 33.The tables must be aliased. The FULL. The OR operator cannot be used to link outer join conditions. or LEFT keyword must be included. (*) Outer joins are always evaluated before other types of joins in the query. If it selects rows from the two tables that have equal values in all matched columns. When the NATURAL JOIN clause is based on all columns in the two tables that have the same name. Which of the following conditions will cause an error on a NATURAL JOIN? Review (1) Points Mark for When you attempt to write it as an equijoin. (*) 35.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. then an error is returned. (*) 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) . If the columns having the same names have different 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 . You need to join two tables that have two columns with the same name and compatible data types.Equijoin (*) Self join (*) Nonequijoin Simple join (*) full outer join 36. ' || b. b. c.physician_id = c. Evaluate this SELECT statement: SELECT a. for Review (1) Points Which of the following statements is the simplest description of a nonequijoin? Mark A join condition containing something other than an equality operator (*) A join condition that is not equal to other joins.lname || '.admission FROM patient a JOIN physician b ON (b.fname as "Physician".Self-join 37.fname as "Patient".lname || '. .physician_id). ' || a. A join that joins a table to itself 38. A join condition that includes the (+) on the left hand side. patient_id).physician_id).patient_id = c. (*) JOIN admission c ON (a.JOIN admission c ON (a.physician_id = c.patient_id = c. (1) Points The primary advantage of using JOIN ON is: Mark for Review The join happens automatically based on matching column names and data types . Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b.patient_id) 39. 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. (*) The ORDER table contains a column that has a referential constraint to a column in the PRODUCT table. The CUST_ID column in the ORDER table contains null values that need to be displayed. . The CUSTOMER and ORDER tables have no columns with identical names. The CUSTOMER and ORDER tables have a corresponding column. CUST_ID. 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. department_id. e. e. d. d. SELECT e. d.department_id. e.last_name.department_name .department_id = d. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e.department_id.last_name.department_id).department_id = d.41. (*) SELECT e.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e. e.department_id.last_name. d.department_name FROM employees e NATURAL JOIN departments d. Which query will retrieve all the rows in the EMPLOYEES table.last_name.department_id).department_name FROM employees e LEFT OUTER JOIN departments d ON (e. SELECT e. 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.FROM employees e JOIN departments d USING (e. 42.department_id = d. What should be included in a SELECT statement to return NULL values from all tables? Mark for Review (1) Points natural joins .department_id). left outer joins full outer joins (*) right outer joins 44. required? (1) Points If a select list contains both a column as well as a group function then what clause is Mark for Review having clause join clause order by clause group by clause (*) 45. Evaluate this SELECT statement: . SELECT MIN(hire_date). (*) The the earliest hire date in the EMPLOYEE table. (1) Points Which statement about group functions is true? Mark for Review . Which values are displayed? Mark for Review (1) Points The earliest hire date in each department. The hire dates in the EMPLOYEE table that contain NULL values 46. The latest hire date in the EMPLOYEE table. dept_id FROM employee GROUP BY dept_id. (*) Group functions can only be used in a SELECT list. A query that includes a group function in the SELECT list must include a GROUP BY clause. Group functions can be used in a WHERE clause. 47.Group functions ignore null values. Group functions can be nested to a depth of? Mark for Review (1) Points three four two (*) . The VENDORS table contains these columns: VENDOR_ID NUMBER Primary Key NAME VARCHAR2(30) LOCATION_ID NUMBER ORDER_DT DATE ORDER_AMOUNT NUMBER(8.Group functions cannot be nested. 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. 48.2) . Refer to Section 5 50. Which group function will you use? Mark for Review . You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. MIN(AVG(order_amount)) (*) Incorrect Incorrect.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. Mark for Review (1) Points a row set. ignore a row set.(1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE 51. Group functions return a value for ________________ and ________________ null values in their computations. ignore (*) each row. include . and STDDEV functions can be used with which of the following? Mark for Review (1) Points Only numeric data types (*) . include 52.each row. SUM. The AVG. You need to calculate the average salary of employees in each department. VARIANCE. Which group function will you use? Mark for Review (1) Points AVG (*) MEAN MEDIAN AVERAGE 53. Integers only Any data type All except numeric 54. prod_qty) FROM products. 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. What happens when this statement is issued? Mark for Review . An error occurs.2) HIRE_DATE DATE BONUS NUMBER(7. (*) 55.2) COMM_PCT NUMBER(4. The values in the PROD_PRICE column and the PROD_QTY column are averaged together.(1) Points Both the average price and the average quantity of the products are returned.2) . Only the average quantity of the products is returned. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(9. Which SELECT statement will calculate the number of rows in the PRODUCTS table? for Review (1) Points Mark .Which three functions could be used with the HIRE_DATE.) Mark for Review (1) Points (Choose all correct answers) MAX (*) SUM AVG MIN (*) COUNT (*) 56. LAST_NAME. or SALARY columns? (Choose three. Which SQL statement did you execute? Mark for Review (1) Points .05 PRICE DISCOUNT 0.60 867950 985490 945809 5.SELECT COUNT(products).50 PRODUCT_ID 0. SELECT COUNT (*) FROM products.99 768385 862459 849869 5. SELECT COUNT FROM products.15 You query the LINE_ITEM table and a value of 5 is returned.25 543949 349302 453235 4. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID 890898 847589 848399 8. (*) SELECT ROWCOUNT FROM products 57.10 0.60 954039 439203 438925 5. SELECT AVG(discount) FROM line_it 58. SELECT COUNT(*) FROM line_item.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 COUNT(discount) FROM line_item. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7. (*) SELECT SUM(discount) FROM line_item. last_name. department_id. first_name.SELECT * FROM employees WHERE salary > 50000. (*) SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id. SELECT COUNT(*) FROM employees WHERE salary > 50000. SELECT COUNT(*) FROM employees WHERE salary < 50000. salary. SELECT * FROM employees WHERE salary < 50000. . 59. An error occurs because no WHERE clause is included in the SELECT statement. Evaluate this statement: . Evaluate this SELECT statement: SELECT COUNT(*) FROM products. 60. Which statement is true? Mark for Review (1) Points The number of rows in the table is displayed. An error occurs due to an error in the SELECT clause. (*) The number of unique PRODUCT_IDs in the table is displayed. AVG(salary) WHERE job_id <> 69879 (*) GROUP BY job_id. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. Which clauses restricts the result? Choose two. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. Mark for Review (1) Points (Choose all correct answers) SELECT department_id.SELECT department_id. department_id HAVING AVG(salary) > 35000 (*) . 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. The PLAYERS and TEAMS tables contain these columns: PLAYERS PLAYER_ID NUMBER NOT NULL. Which SELECT statement will produce the desired result? Mark for Review (1) Points SELECT t.61. . teams t ON (p.team_id = t. Primary Key TEAM_NAME VARCHAR2 (25) You need to create a report that lists the names of each team with more than five pitchers.team_name.team_name. COUNT(p.player_id) FROM players p.position) = 'PITCHER' GROUP BY t.team_id) WHERE UPPER(p. SELECT t.player_id) FROM players p JOIN teams t ON (p.team_name HAVING COUNT(p.team_name.team_id = t. SELECT t. SELECT t.player_id) > 5.position) = 'PITCHER' GROUP BY t.position) = 'PITCHER' GROUP BY t.team_id = t.team_id) WHERE UPPER(p.team_id = t. teams t ON (p. The MANUFACTURER table contains these columns: MANUFACTURER_ID NUMBER MANUFACTURER_NAME VARCHAR2(30) TYPE VARCHAR2(25) .team_id) WHERE UPPER(p.team_name HAVING COUNT(p. COUNT(p. (*) 62. COUNT(p.team_id) WHERE UPPER(p.team_name.player_id) > 5.position) = 'PITCHER' HAVING COUNT(p.team_name.player_id) FROM players p.player_id) FROM players JOIN teams t ON (p.player_id) > 5. COUNT(p. COUNT(type) FROM manufacturer GROUP BY location_id. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. COUNT(DISTINCT type) FROM manufacturer.LOCATION_ID NUMBER You need to display the number of unique types of manufacturers at each location. (*) SELECT location_id. SELECT location_id. Which SELECT statement should you use? Mark for Review (1) Points SELECT location_id. . 2) Which two clauses represent valid uses of aggregate functions? (Choose three. 0)) (*) .SELECT location_id. The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8. COUNT(DISTINCT type) FROM manufacturer GROUP BY type.) Mark for Review (1) Points (Choose all correct answers) ORDER BY AVG(salary) GROUP BY MAX(salary) (*) SELECT AVG(NVL(salary. 3. Evaluate this SELECT statement: . 66. rows are not sorted when a GROUP BY clause is used.HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) 65. You must use the HAVING clause with the GROUP BY clause. (*) You can use a column alias in a GROUP BY clause. you use should a WHERE clause. By default. 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. dept_id FROM employee GROUP BY dept_id.SELECT SUM(salary). The EMPLOYEES table contains these columns: ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER . 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. SALARY NUMBER (7. name. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing. . The WHERE clause contains a syntax error. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. name ORDER BY hire_date. id_number. The SALARY column is NOT included in the GROUP BY clause.2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. department_id. (*) Incorrect Incorrect.The HIRE_DATE column is NOT included in the GROUP BY clause. Page 67 of 100 Next Summary Examine the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8.2) Which of the following scenarios would require a subquery to return the desired results? Mark for Review (1) Points . Refer to Section 6 Previous 68.2) OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. You need to display all the orders that were placed on the same day as order number 25950. You need to display all the orders that were placed on a certain date.You need to display the date each customer account was opened. Refer to Section 6 Previous Page 68 of 100 Next Summary 69. You need to display each date that a customer placed an order. (*) Incorrect Incorrect. Which operator can be used with a multiple-row subquery? Mark for Review (1) Points IN (*) . (*) SELECT product_name FROM products WHERE cost > AVG(cost). 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).<> = LIKE 70. . product_name FROM products WHERE cost > AVG(cost) GROUP by product_name. 71.SELECT AVG(cost). SELECT product_name FROM (SELECT AVG(cost) FROM product) WHERE cost > AVG(cost). Using a subquery in which clause will return a syntax error? Mark for Review (1) Points WHERE FROM HAVING . You need to display all the players whose salaries are greater than or equal to John Brown's salary. Which best describes a single-row subquery? Mark for Review (1) Points a query that returns only one row from the inner SELECT statement (*) . (*) 72. Which comparison operator should you use? Mark for Review (1) Points = > <= >= (*) 73.There are no places you cannot place subqueries. DEPARTMENT. Examine the structure of the EMPLOYEE. 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) .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. Which statement about the <> operator is true? Mark for Review (1) Points The <> operator is NOT a valid SQL operator. 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.DATE DATE CUSTOMER_ID NUMBER(9) You want to display all employees who had an order after the Sales department was established. . The <> operator can be used when a single-row subquery returns only one row.The <> operator CANNOT be used in a single-row subquery. Which operator or keyword cannot be used with a multiple-row subquery? Review (1) Points Mark for ALL ANY = (*) > . The <> operator returns the same result as the ANY operator in a subquery. (*) 76. name FROM players WHERE team_id IN (SELECT team_id &nbspFROM teams . Evaluate this SELECT statement: SELECT player_id.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. (*) A syntax error in the outer query would be returned. (*) . All the rows in the PLAYER table would be returned by the outer query. subquery? (1) Points What would happen if you attempted to use a single-row operator with a multiple-row Mark for Review An error would be returned. A syntax error in the inner query would be returned.&nbspWHERE 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. 79. Incorrect. Refer to Section 6 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 . All the rows will be selected. Incorrect 80.No rows will be selected. The data returned may or may not be correct. 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. 'DALLAS ')). .15 WHERE manufacturers_id = (SELECT id &nbspFROM manufacturers &nbspWHERE UPPER(location) IN('ATLANTA '. 'BOSTON '. 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.A query that returns one or more 81. manufacturers_id)). price.SELECT parts_name. SELECT parts_name. (*) SELECT parts_name FROM (SELECT AVG(cost) . cost FROM parts WHERE manufacturers_id IN (SELECT id &nbspFROM manufacturers m &nbspJOIN part p ON (m. price. cost FROM parts WHERE manufacturers_id != (SELECT id &nbspFROM manufacturers &nbspWHERE LOWER(name) = 'cost plus').id = p. &nbspFROM manufacturers) &nbspWHERE cost > AVG(cost). Which of the following best describes the meaning of the ANY operator? Review (1) Points Mark for 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 . Correct Correct Previous Page 81 of 100 Next Summary 82. (*) .Equal to each value in the list 83. Multiple-row subqueries can only be used in SEL true? 84. Which statement about single-row and multiple-row subqueries is true? Review (1) Points Mark for 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. Which statement about the ANY operator when used with a multiple-row subquery is Mark for Review (1) Points The ANY operator compares every value returned by the subquery. =. The ANY operator is a synonym for the ALL operator.. 85.AND. which comparison operator(s) can you use? Mark for Review (1) Points IN.. <.. The ANY operator can be used with the LIKE and IN operators. You need to create a SELECT statement that contains a multiple-row subquery. and ALL (*) LIKE BETWEEN..The ANY operator can be used with the DISTINCT keyword. ANY. and > . You need to display all the products that cost more than the maximum cost of every product produced in Japan. 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 .86. Which multiple-row comparison operator could you use? Mark for Review (1) Points >ANY (*) NOT=ALL IN >IN 87. with an identical structure. stu_type_id. into the new table. (*) An error occurs because the FT_STUDENTS table already exists. first_name.You want to insert all fulltime students. named FT_STUDENTS. last_name. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id. who have a STU_TYPE_ID value of "F". The PRODUCTS table contains these columns: . An error occurs because you CANNOT use a subquery in an INSERT statement. dob. 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. 88.You create another table. An error occurs because the INSERT statement does NOT contain a VALUES clause. enroll_date FROM students WHERE UPPER(stu_type_id) = 'F'). (*) The row was created with the correct data in two of three columns.'6-foot nylon leash'. . 10).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. 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. 'tflanders'. location) VALUES (200. . Because the new customer has not had a credit check. poc. The row was created completely wrong. company. No data ended up in the correct columns. 'InterCargo'. 89. 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.The row was created with the correct data in one of the three columns. You have been instructed to add a new customer to the CUSTOMERS table. 'samerica'). you should not add an amount to the CREDIT column. 0. poc. 'samerica'). location) (200. tflanders.(*) INSERT INTO customers VALUES (200. Which DML statement should you use? for Review (1) Points Mark UPDATE INSERT (*) . 'tflanders'. 'tflanders'. 'InterCargo'. null. InterCargo. 'samerica'). credit. company. 'InterCargo'. 90. 0. You need to add a row to an existing table. samerica). INSERT INTO customers VALUES (200. (*) INSERT INTO customers VALUES (cust_id. 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. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table using one UPDATE statement. What keyword in an UPDATE statement speficies the columns you want to change? for Review (1) Points Mark .DELETE CREATE 91. has informed you that she was recently married. Janet Roper. Her new last name is Cooper. Janet is the only person with the last name of Roper that is employed by the company.SELECT WHERE SET (*) HAVING 93. 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 . and she has requested that you update her name in the employee database. One of the sales representatives. UPDATE employees SET cooper = 'lname' WHERE lname = 'roper'. UPDATE employees SET lname = 'roper' WHERE lname = 'cooper'.UPDATE employees SET lname = 'cooper' WHERE lname = 'roper'. . (*) UPDATE employees lname = 'cooper' WHERE lname = 'roper'. 94. Which two commands can be used to modify existing data in a database row? Review (1) Points Mark for (Choose all correct answers) DELETE INSERT (*) SELECT UPDATE (*) 95. whose unique employee identification number is 348. You need to delete a record in the EMPLOYEES table for Tim Jones. The EMPLOYEES table contains these columns: ID_NUM NUMBER(5) PRIMARY KEY LNAME VARCHAR2(20) FNAME VARCHAR2(20) . Incorrect 96. DELETE * FROM employees WHERE id_num = 348.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. Incorrect. Refer to Section 7 The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns: TEACHERS . (*) DELETE FROM employees WHERE lname = jones. DELETE 'jones' FROM employees. You need to create a report to display the teachers who were hired more than five years ago.TEACHER_ID NUMBER(5) NAME VARCHAR2(25) SUBJECT_ID NUMBER(5) HIRE_DATE DATE SALARY NUMBER(9. You need to display the names of the teachers who teach classes that start within the next week. .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. 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 create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. Refer to Section 7 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. (*) Incorrect 96. Incorrect. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. 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. Examine the structures of the PRODUCTS and SUPPLIERS tables: SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. 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 were hired more than five years ago.You need to display the start date for each class taught by a given teacher. Primary Key . (*) 97. . (*) DELETE FROM products WHERE UPPER(city) = 'ATLANTA'.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'). Examine the structures of the PRODUCTS and SUPPLIERS tables: SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. 97. DELETE FROM products WHERE supplier_id IN (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA').DELETE FROM products WHERE supplier_id = (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA'). 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. Which script should you use? Mark for 98. What would happen if you issued a DELETE statement without a WHERE clause? for Review (1) Points Mark All the rows in the table would be deleted. 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. (*) An error message would be returned.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 statement should you execute? Mark for Review (1) Points . Incorrect Incorrect. Only one row would be deleted.2) BONUS NUMBER(9. 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. Refer to Section 7 99. all employees in department 10 have the same salary value. Currently.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.No rows would be deleted. for Review (1) Points Which of the following represents the correct syntax for an INSERT statement? Mark . (*) UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10). UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898) WHERE dept = 10. 100. UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898).UPDATE employee SET salary = SELECT salary FROM employee WHERE emp_id = 89898. Section 1 Lesson 1 (Answer all questions in this section) 1. '37777'). and question scores below. 123 Main Street. '123 Main Street'. Test: Mid Term Exam .INSERT VALUES INTO customers (3178 J. INSERT INTO customers VALUES ('3178'. Which SQL function can be used to remove heading or trailing characters (or both) from a character string? Mark for Review (1) Points .. 'Smith'. J. feedback. 'TN'. Smith 123 Main Street Nashville TN 37777. Smith.'. (*) INSERT customers VALUES 3178. Nashville. TN. INSERT INTO customers VALUES '3178' 'J.Database Programming with SQL Review your answers. 'J. 'Nashville'.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777'. 37777. An asterisk (*) indicates a correct answer. (*) The CONCAT function can only be used on character strings. Which three statements about functions are true? (Choose three. (*) . (*) The ROUND number function rounds a value to a specified decimal place or the nearest whole number.LPAD CUT NVL2 TRIM (*) Correct 2.) Mark for Review (1) Points (Choose all correct answers) The SYSDATE function returns the Oracle Server date and time. The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length. not on numbers. Correct 3. CONCAT. 1. first_name)). SUBSTR SUBSTR. LOWER CONCAT. CONCAT. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. SUBSTR. SUBSTR. 5) "ID" FROM employee. In which order are the functions evaluated? Mark for Review (1) Points LOWER. LOWER (*) Correct . CONCAT LOWER. You issue this SQL statement: SELECT INSTR ('organizational sales'. Which value is returned by this command? Mark for Review . You need to return a portion of each employee's last name. 'al') FROM dual.4. Which character function should you use? Mark for Review (1) Points INSTR TRUNC SUBSTR (*) CONCAT Correct 5. beginning with the first character up to the fifth character. '$')SALARY FROM employees. size of 15 and the column labeled SALARY. What will the following SQL statemtent display? SELECT last_name. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value. 15. LPAD(salary. .(1) Points 1 2 13 (*) 17 Correct 6. (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. The last name and salary for all employees with the format of the salary 15 characters long. The email address of each employee in the EMPLOYEE table. leftpadded with the $ 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. What will this SELECT statement display? Mark for Review (1) Points The longest e-mail address in the EMPLOYEE table." Correct 7. . Evaluate this SELECT statement: SELECT LENGTH(email) FROM employee. Which two functions can be used to manipulate number or date column values. Correct Section 1 Lesson 2 (Answer all questions in this section) 8. but NOT character column values? (Choose two.) Mark for Review (1) Points (Choose all correct answers) RPAD TRUNC (*) ROUND (*) INSTR .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. 'MONTH') FROM employee. (*) SELECT ROUND(hire_date.CONCAT Correct 9. 'MI') FROM employee. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review (1) Points SELECT TRUNC(hire_date. . SELECT ROUND(hire_date. SELECT TRUNC(hire_date. 'MONTH') FROM employee. 'MON') FROM employee. Refer to Section 1 Lesson 3 10. You issue this SQL statement: SELECT TRUNC(751.Incorrect.3 .367. Which value does this statement display? Mark for Review (1) Points 700 750 (*) 751 751.-1) FROM dual. Section 1 Lesson 3 (Answer all questions in this section) 11. and question scores below. (*) . An asterisk (*) indicates a correct answer. SELECT (SYSDATE .hire_date) + 10*8 FROM employees. Which SELECT statement will NOT return a date value? Mark for Review (1) Points SELECT (30 + hire_date) + 1440/24 FROM employees. feedback.Correct Page 1 of 10 Test: Mid Term Exam .Database Programming with SQL Review your answers. TO_DATE('25-JUN-02') + hire_date FROM employees. Which function should you use? Mark for Review (1) Points ROUND TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN .SYSDATE) + TO_DATE('25-JUN-02') FROM employees. SELECT (hire_date . Correct 12. You need to subtract three months from the current date.SELECT SYSDATE . Which element would you use? Mark for Review (1) Points RR YY .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). 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 .YYYY YEAR (*) Correct 15. 00.000. 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 . Each employee's salary must be displayed in the following format: $000. All Human Resources data is stored in a table named EMPLOYEES. Correct Section 2 Lesson 1 (Answer all questions in this section) 16.No value is returned because the SELECT statement generates an error. You have been asked to create a report that displays each employee's name and salary. Tuesday. total FROM customers NATURAL JOIN orders . 'fmdd. 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. TO_CHAR (sysdate. (*) The TO_CHAR function can only be used on DATE columns. The TO_CHAR function can be used to remove text from column data that will be returned by the database. The report's date should be displayed in the Day.500.17. dy month. The TO_CHAR function can be used to display dates and numbers according to formatting conventions that are supported by Oracle. Which statement should you issue? Mark for Review (1) Points SELECT companyname. 2004 ). Date Month. Correct 18. yyyy'). Year format (For example. You have been asked to create a report that lists all customers who have placed orders of at least $2. 13 April. total FROM customers NATURAL JOIN orders WHERE total >= 2500. total FROM customers NATURAL JOIN orders WHERE total >= 2500. TO_DATE (sysdate. SELECT companyname. Which SQL Statement should you use to display the prices in this format: "$00. total FROM customers NATURAL JOIN orders WHERE total >= 2500. yyyy'). 'fmDay. TO_DATE (date. yyyy'). Refer to Section 2 19. yyyy'). dd Month.WHERE total >= 2500. 'dd. TO_CHAR (sysdate. SELECT companyname. SELECT companyname. 'day. dy month. dd month.30"? Mark for Review (1) Points . (*) Incorrect. Single row functions cannot modify a data type. '$99.SELECT TO_CHAR(price. Single row functions can be nested. SELECT TO_CHAR(price.900. '$99.99") FROM product.99') FROM product. (*) Single row functions return one or more results per row. "$99. SELECT TO_NUMBER(price. .900. but can return multiple values. (*) SELECT TO_CHAR(price. Correct 20.900.990.99') FROM product.99') FROM product. Which statement concerning single row functions is true? Mark for Review (1) Points Single row functions can accept only one argument. '$99. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2 (25) FIRST_NAME VARCHAR2 (25) .Correct Page 2 of 10 Test: Mid Term Exam . An asterisk (*) indicates a correct answer. and question scores below.Database Programming with SQL Review your answers. Section 2 Lesson 1 (Answer all questions in this section) 21. feedback. 00"? Mark for Review (1) Points SELECT TO_CHAR(salary. SELECT TO_CHAR(salary. SELECT TO_NUM(salary.999.99') FROM employees. '$999. (*) .999') FROM employees. SELECT TO_NUM(salary. '$999.SALARY NUMBER(6) You need to create a report to display the salaries of all employees.00') FROM employees.00') FROM employees. '$999.000.990.999. '$999. Which script should you use to display the salaries in format: "$45. but not NVL and NVL2. but not COALESCE.Correct Section 2 Lesson 2 (Answer all questions in this section) 22. Correct 23. NVL and COALESCE. NVL. can be used with group functions to replace null values. can be used with group functions to replace null values. and COALESCE can be used with group functions to replace null values. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. can be used with group functions to replace null values. (*) COALESCE. but not NVL2. The STYLES table contains this data: . NVL2. 00 968950 SANDAL 85909 10.00 890890 LOAFER 89789 14.00 758960 SANDAL 86979 . cost. 0) < 15. style_name.00 ORDER BY category. cost FROM styles WHERE style_name LIKE 'SANDAL' AND NVL(cost. Which result will the query provide? Mark for Review (1) Points STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 857689 HEEL 85940 11.00 809090 LOAFER 89098 10.00 869506 SANDAL 89690 15.00 758960 SANDAL 86979 Evaluate this SELECT statement: SELECT style_id.00 968950 SANDAL 85909 10.STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. category. 00 869506 SANDAL 89690 15.00 758960 SANDAL 86979 (*) .00 758960 SANDAL 86979 STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85909 12.00 968950 SANDAL 85909 10.00 895840 SANDAL 85940 12.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. 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) .Correct 24. s. e.lname.fname.sales FROM employees e.lname.emp_id = s.fname.fname. sales Q FROM employees e.25.emp_id AND revenue >= 100000.sales FROM employees.lname.emp_id = s.000 in revenue. s. e. SELECT e. . sales WHERE e. (*) SELECT e. sales s WHERE e.sales FROM employees e. Which query should you issue? Mark for Review (1) Points SELECT e. lname. e.emp_id AND revenue > 100000. Your have two tables named EMPLOYEES and SALES.emp_id = s. sales s WHERE e. SELECT fname.emp_id AND revenue >= 100000. sales s WHERE e. s.emp_id AND revenue > 100000. You want to identify the sales representatives who have generated at least $100.emp_id = s. Correct 26. 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 (*) . 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. The FROM clause represents the join criteria. Which statement about the join syntax of a SELECT statement is true? Mark for Review (1) Points The ON keyword must be included. 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. (*) Correct . The WHERE clause represents the join criteria. one column to the next column.The table is joined to itself. The JOIN keyword must be included. 29. .cust_id = s. 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.company. the company and the total sales? Mark for Review (1) Points SELECT c. sales s WHERE c.cust_id.total_sales FROM customers c. SELECT cust_id. total_sales FROM customers. c. s. sales WHERE cust_id = cust_id. company.cust_id (+). company. sales s WHERE c. salary . first_name.cust_id = s. Correct 30. salary FROM employees WHERE salary > 25000 AND dept_id = 10.company.cust_id.total_sales FROM customers c. total_sales FROM customers c.cust_id = s. (*) SELECT cust_id. Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT last_name. first_name. s.SELECT c.cust_id.cust_id. c.000 per year. sales s WHERE c. SELECT last_name. You need to create a report that lists all employees in the Sales department who do not earn $25. SELECT last_name. (*) Correct Page 3 of 10 . salary FROM employees WHERE salary != 25000 AND dept_id = 10. salary FROM employees WHERE salary <= 25000 AND dept_id = 10.FROM employees WHERE salary = 25000 AND dept_id = 10. first_name. first_name. SELECT last_name. .. 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. Section 3 Lesson 4 (Answer all questions in this section) 31. and question scores below. and IN IN and = Correct .. feedback.. An asterisk (*) indicates a correct answer.Test: Mid Term Exam .AND.Database Programming with SQL Review your answers. 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.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. . An outer join will return data only if both tables contain an identical pair of columns. (*) Correct Section 4 Lesson 2 (Answer all questions in this section) 34.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. 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 . Correct 35. (*) Columns with the same names must have compatible data types. Which statement about a natural join is true? Mark for Review (1) Points Columns with the same names must have identical data types. Correct 36. Columns with the same names must have the same precision and datatype. Columns with the same names cannot be included in the SELECT list of the query. 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 (*) . ' || b. Evaluate this SELECT statement: SELECT a. b.lname || '.fname as "Patient".Self join (*) Nonequijoin Simple join (*) full outer join Incorrect.physician_id). JOIN admission c .fname as "Physician".physician_id = c.lname || '. Refer to Section 4 Section 4 Lesson 3 (Answer all questions in this section) 37. ' || a.admission FROM patient a JOIN physician b ON (b. c. physician_id). (*) JOIN admission c ON (a.patient_id = c.patient_id). 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.ON (a.physician_id = c. Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b.patient_id) Correct 38.patient_id = c. . 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.A join condition that includes the (+) on the left hand side. A join that joins a table to itself Correct 39. 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 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. (*) 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.Database Programming with SQL . Correct Page 4 of 10 Test: Mid Term Exam . 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 . Section 4 Lesson 4 (Answer all questions in this section) 41. feedback. An asterisk (*) indicates a correct answer.Review your answers. Refer to Section 4 42. and question scores below. 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. department_id. d. SELECT e.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e.department_id = d.last_name. Which query will retrieve all the rows in the EMPLOYEES table. e.department_id).LEFT OUTER JOIN and FULL OUTER JOIN (*) RIGHT OUTER JOIN and LEFT OUTER JOIN USING and HAVING OUTER JOIN and USING Correct 43. . even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e.last_name. d.department_name FROM employees e NATURAL JOIN departments d. e.department_id. last_name.department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_id). e.department_id = d. d. COUNT(*) FROM employees GROUP BY job_id.department_id.SELECT e.department_id).department_id = d. d. Correct Section 5 Lesson 1 (Answer all questions in this section) 44.last_name. (*) SELECT e. What will the following SQL Statement do? SELECT job_id.department_name FROM employees e JOIN departments d USING (e. . e.department_id. AVG (salary)"Average" FROM employees GROUP BY Department. Displays each job id and the number of people assigned to that job id.Mark for Review (1) Points Displays all the employees and groups them by job. Correct 45. Displays all the jobs with as many people as there are jobs. What is the best explanation as to why this SQL statement will NOT execute? SELECT department_id "Department". You cannot use a column alias in the GROUP BY clause. (*) Displays only the number of job_ids. Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. (*) . A GROUP BY clause cannot be used without an ORDER BY clause. Correct 47. (*) The last column listed in the GROUP BY clause is the most major grouping.The GROUP BY clause must have something to GROUP. The GROUP BY clause can contain an aggregate function. Correct 46. Group functions can be nested to a depth of? Mark for Review . The department id is not listed in the departments table. 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. Correct Section 5 Lesson 2 (Answer all questions in this section) 48. Which group functions below act on character.(1) Points three four two (*) Group functions cannot be nested. 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 49. Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE . You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. Which group function should you use to calculate this value? Mark for Review (1) Points AVG (*) SUM COUNT STDDEV .2) CATEGORY VARCHAR2(20) You need to calculate the average credit limit for all the customers in each category.Correct 50. 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. The CUSTOMER table contains these columns: CUSTOMER_ID NUMBER(9) FNAME VARCHAR2(25) LNAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7. Correct Page 5 of 10 Test: Mid Term Exam . Which group function would you use to display the average price of all products in the PRODUCTS table? Mark for Review (1) Points SUM . and question scores below. An asterisk (*) indicates a correct answer. feedback.Database Programming with SQL Review your answers. Section 5 Lesson 2 (Answer all questions in this section) 51. 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 . SELECT SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'.00 85490345 5489304 20-MAR-03 BASIC 568.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 You need to determine the average payment amount made by each customer in January.00 89453485 8549038 15-FEB-03 INTEREST 596. 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'. February and March of 2003. . (*) SELECT AVG(payment_amount) FROM payment. MAR). or SALARY columns? (Choose three.2) COMM_PCT NUMBER(4. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(9.) Mark for Review (1) Points (Choose all correct answers) .2) Which three functions could be used with the HIRE_DATE. LAST_NAME.SELECT AVG(payment_amount) FROM payment WHERE TO_CHAR(payment_date) IN (JAN. Correct 54.2) HIRE_DATE DATE BONUS NUMBER(7. FEB. include . include each row. Mark for Review (1) Points a row set. Group functions return a value for ________________ and ________________ null values in their computations. ignore a row set.MAX (*) SUM AVG MIN (*) COUNT (*) Correct 55. ignore (*) each row. Correct Section 5 Lesson 3 (Answer all questions in this section) 56. Incorrect. The COUNT function can be used to determine the number of unique. (*) The COUNT function can be used to find the maximum value in each column. The COUNT function always ignores null values by default. Refer to Section 5 57. The EMPLOYEES table contains these columns: . non-null values in a column. Which statement about the COUNT function is true? Mark for Review (1) Points The COUNT function ignores duplicates by default. 000? Which SELECT would you use? Mark for Review (1) Points SELECT * FROM employees WHERE salary > 50000. SELECT COUNT(*) FROM employees WHERE salary < 50000. SELECT COUNT(*) FROM employees WHERE salary > 50000. SELECT * FROM employees WHERE salary < 50000.2) DEPARTMENT_ID NUMBER(9) You need to display the number of employees whose salary is greater than $50.EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7. (*) . last_name. department_id. first_name.SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id. salary. Group functions can avoid computations involving duplicate values by including which keyword? Mark for Review (1) Points NULL DISTINCT (*) SELECT UNLIKE Correct . Correct 58. Which SQL statement did you execute? Mark for Review (1) Points SELECT COUNT(discount) FROM line_item.59. (*) SELECT SUM(discount) FROM line_item. SELECT COUNT(*) FROM line_item. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT 890898 847589 848399 8.25 0. Correct .15 543949 349302 453235 4.60 954039 439203 438925 5.60 0. SELECT AVG(discount) FROM line_item.10 768385 862459 849869 5.05 867950 985490 945809 5.50 You query the LINE_ITEM table and a value of 5 is returned.99 0. 2) PRICE NUMBER(7.2) QUANTITY NUMBER You display the total of the extended costs for each product category by location. Which SQL statement will display the desired result? Mark for Review (1) Points SELECT category_id. 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.location_id FROM products WHERE price > 25. location_id.00 GROUP BY category_id. The extended cost of each item equals the quantity value multiplied by the cost value. SUM(cost * quantity) TOTAL. You need to include only the products that have a price less than $25.00.Section 6 Lesson 1 (Answer all questions in this section) 60. . SUM(cost * quantity) TOTAL. location_id. SELECT category_id. Refer to Section 6 . location_id FROM products WHERE price < 25. (*) SELECT SUM(cost * quantity) TOTAL FROM products WHERE price < 25.00 GROUP BY location_id.00. Incorrect.SELECT SUM(cost * quantity) TOTAL.00 GROUP BY category_id. location_id FROM products WHERE price < 25. Page 6 of 10 Test: Mid Term Exam .Database Programming with SQL Review your answers. How are the results of this statement sorted? Mark for Review (1) Points . Evaluate this SELECT statement: SELECT SUM(salary). feedback. dept_id FROM employee GROUP BY dept_id. An asterisk (*) indicates a correct answer. Section 6 Lesson 1 (Answer all questions in this section) 61. and question scores below. 2) Which two clauses represent valid uses of aggregate functions? (Choose three.) Mark for Review (1) Points (Choose all correct answers) . The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8.Ascending order by dept_id (*) Descending order by dept_id Ascending order by cumulative salary Descending order by cumulative salary Correct 62. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Correct 63. Which SELECT statement clause allows you to restrict the rows returned. dept_id. mgr_id. based on a group function? Mark for Review (1) Points HAVING SUM(salary) > 100000 (*) .ORDER BY AVG(salary) GROUP BY MAX(salary) (*) SELECT AVG(NVL(salary. mgr_id FROM employee GROUP BY dept_id. Evaluate this SELECT statement: SELECT SUM(salary). Refer to Section 6 64.WHERE SUM(salary) > 100000 WHERE salary > 100000 HAVING salary > 100000 Incorrect. 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. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. (*) . Which SELECT statement should you use? Mark for Review (1) Points SELECT location_id. .SELECT location_id. COUNT(type) FROM manufacturer GROUP BY location_id. dept_id. SELECT location_id. COUNT(DISTINCT type) FROM manufacturer. SELECT location_id. Refer to Section 6 65. Incorrect. department_name FROM employee WHERE dept_id = 1 GROUP BY department. Evaluate this SELECT statement: SELECT SUM(salary). COUNT(DISTINCT type) FROM manufacturer GROUP BY type. 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 can use a column alias in a GROUP BY clause. rows are not sorted when a GROUP BY clause is used. . Refer to Section 6 66.Which clause of the SELECT statement contains a syntax error? Mark for Review (1) Points SELECT FROM WHERE GROUP BY (*) Incorrect. By default. you use should a WHERE clause. You must use the HAVING clause with the GROUP BY clause. 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. Correct 67. (*) SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. . 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' GROUP BY customer_id. Which statement about subqueries is true? Mark for Review (1) Points . COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. Refer to Section 6 Section 6 Lesson 2 (Answer all questions in this section) 68. Incorrect.SELECT customer_id. Subqueries are often used in a WHERE clause to return values for an unknown conditional value. after the main or outer query executes.Subqueries should be enclosed in double quotation marks. Subqueries cannot contain group functions. Correct 69. (*) Subqueries generally execute last. Which operator can be used with subqueries that return only one row? Mark for Review (1) Points LIKE (*) ANY ALL IN Correct . If you use the equality operator (=) with a subquery.70. 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 . Section 6 Lesson 2 (Answer all questions in this section) 71.Database Programming with SQL Review your answers.Test: Mid Term Exam . Which comparison operator should you use? Mark for Review (1) Points = > <= >= (*) Correct 72. An asterisk (*) indicates a correct answer. Examine the structures of the CUSTOMER and ORDER_HISTORY tables: . feedback. You need to display all the players whose salaries are greater than or equal to John Brown's salary. and question scores below. (*) .CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8. You need to display all the orders that were placed on a certain date.2) OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. You need to display each date that a customer placed an order.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 all the orders that were placed on the same day as order number 25950. However. you are not sure which supervisor ID belongs to Brad Carter. You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id .Correct Section 6 Lesson 3 (Answer all questions in this section) 73. 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'). FROM employees WHERE last_name = 'Carter'). SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter'). (*) Correct . SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id FROM supervisors WHERE last_name = 'Carter'). 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. Examine the structure of the EMPLOYEE. Which of the following constructs would you use? Mark for Review (1) Points a group function a single-row subquery (*) .74. DEPARTMENT. 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 . Only the rows with CUSTOMER_ID values equal to null would be selected. .00).Section 6 Lesson 4 (Answer all questions in this section) 76. (*) All the rows in the table would be selected. name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. Evaluate this SELECT statement: SELECT customer_id. No rows would be returned by the outer query. What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. Correct 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). 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. . 00 89453485 8549038 15-FEB-03 INTEREST 596. 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 This statement fails when executed: . All of the above. (*) Correct 79.SELECT description FROM d_types WHERE code = ANY (SELECT type_code FROM d_songs).00 85490345 5489304 20-MAR-03 BASIC 568. SELECT description FROM d_types WHERE code <> ALL (SELECT type_code FROM d_songs). Remove the parentheses surrounding the nested SELECT statement.00 OR payment_date = '20-MAR-2003'). (*) Remove the quotes surrounding the date value in the OR clause. Change the comparison operator to a single-row operator. Which change could correct the problem? Mark for Review (1) Points Change the outer query WHERE clause to 'WHERE payment_id IN'. payment_type FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_amount = 596. What is wrong with the following query? . Correct 80.SELECT customer_id. Correct Page 8 of 10 . (*) Subquery references the wrong table in the WHERE clause.SELECT employee_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. Nothing. last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). it will run without problems. 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. and question scores below.Database Programming with SQL Review your answers.Test: Mid Term Exam . name FROM players WHERE team_id IN (SELECT team_id FROM teams WHERE team_id > 300 AND salary_cap > 400000). An asterisk (*) indicates a correct answer. feedback. Evaluate this SELECT statement: SELECT player_id. Section 6 Lesson 4 (Answer all questions in this section) 81. (*) . A syntax error in the inner query would be returned. All the rows in the PLAYER table would be returned by the outer query.A syntax error in the outer query would be returned. The results of the inner query are returned to the outer query. first_name FROM customer WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). Correct 82. Evaluate this SELECT statement that includes a subquery: SELECT last_name. Which statement is true about the given subquery? Mark for Review (1) Points The outer query executes before the nested subquery. (*) . Correct 84. (*) Single-row operators can be used with both single-row and multiple-row subqueries. Correct 83. Multiple-row subqueries can be used with both single-row and multiple-row operators.An error occurs if the either the inner or outer queries do not return a value. or an error occurs. Both the inner and outer queries must return a value. which comparison operator(s) can you use? Mark for Review (1) Points . You need to create a SELECT statement that contains a multiple-row subquery. Multiple-row subqueries can only be used in SELECT statements. 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. =. and > Correct 85... and ALL (*) LIKE BETWEEN. 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. <.IN. ANY.AND. . The ANY operator can be used with the LIKE and IN operators. The ANY operator is a synonym for the ALL operator.. The data returned may or may not be correct. All the rows will be selected. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. (*) No rows will be selected.Correct 86. What could you use in the INSERT statement to accomplish this task? Mark for Review . 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. Correct Section 7 Lesson 1 (Answer all questions in this section) 87. (1) Points an ON clause a SET clause a subquery (*) a function Correct 88.2) QTY_IN_STOCK NUMBER(4) LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE Which INSERT statement will execute successfully? .2) COST NUMBER (5. The PRODUCTS table contains these columns: PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. product_name.09. 'Cable'). (*) INSERT INTO products VALUES (2958. Because the new customer has not had a credit check. INSERT INTO products(product_id. INSERT INTO products(product_id. Correct 89. 'Cable'. product_name) VALUES (2958. 7. 4.Mark for Review (1) Points INSERT INTO products VALUES (2958. 7.09. 700). 8690.04. You have been instructed to add a new customer to the CUSTOMERS table. 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 .04. 4. 'Cable'. SYSDATE). 8690. 'Cable'. you should not add an amount to the CREDIT column. supplier_id VALUES (2958. SYSDATE). 8690. samerica). 0. Correct . INSERT INTO customers VALUES (200. 'InterCargo'. company. credit. InterCargo. 'InterCargo'. 'tflanders'. 'samerica'). company. poc. (*) INSERT INTO customers VALUES (cust_id. 'tflanders'.(1) Points (Choose all correct answers) INSERT INTO customers (cust_id. (*) INSERT INTO customers VALUES (200. 0. 'samerica'). location) (200. poc. 'tflanders'. 'InterCargo'. null. 'samerica'). location) VALUES (200. tflanders. manager_id. 1700). The following SQL statement will execute which of the following? INSERT INTO departments (department_id. 100.90. 'Public Relations'. 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 . location_id) VALUES (70. department_name. Assume all the column names are correct. Test: Mid Term Exam .Database Programming with SQL Review your answers. 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 . feedback. You need to remove a row from the EMPLOYEE table. Section 7 Lesson 2 (Answer all questions in this section) 91. An asterisk (*) indicates a correct answer. and question scores below. Her employee ID is still 189. One of your employees was recently married. CREATE . UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. CREATE MERGE. however. (*) Correct 93. Which two commands can be used to create new rows? Mark for Review (1) Points INSERT.92. You want to enter a new record into the CUSTOMERS table. INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. 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. bonus = bonus * 1. (*) . You also need to increase the bonus for all employees in department 10 by 15 percent. 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. Which statement should you use? Mark for Review (1) Points UPDATE employees SET salary = salary * 1.10.2) You need to increase the salary for all employees in department 10 by 10 percent.2) BONUS NUMBER(9.15 WHERE dept = 10. bonus = bonus * .10 AND bonus = bonus * 1.UPDATE employees SET salary = salary * 1. UPDATE employees SET (salary = salary * 1.15 WHERE dept = 10. has informed you that she was recently married. Her new last name is Cooper. Refer to Section 7 95. One of the sales representatives. UPDATE employees SET salary = salary * . Incorrect.10.15) WHERE dept = 10. Janet Roper. Janet is the only person with the last name of Roper that is employed by the company. and she has requested that you update her name in the employee database.15 WHERE dept = 10. The EMPLOYEES table contains these columns and all data is stored in lowercase: EMP_ID NUMBER(10) PRIMARY KEY LNAME VARCHAR2(20) .10) SET (bonus = bonus * 1. UPDATE employees SET lname = 'roper' WHERE lname = 'cooper'. (*) UPDATE employees lname = 'cooper' WHERE lname = 'roper'. UPDATE employees .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'. Only one row would be deleted. Which of the following represents the correct syntax for an INSERT statement? Mark for Review (1) Points . (*) An error message would be returned.SET cooper = 'lname' WHERE lname = 'roper'. 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. Correct 97. Correct 96. No rows would be deleted. 'TN'.125. 123 Main Street. (*) INSERT customers VALUES 3178.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777'.'. Nashville.. Smith 123 Main Street Nashville TN 37777. J. 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. '123 Main Street'. Smith.5 percent. TN. 'J. 'Smith'. INSERT INTO customers VALUES ('3178'. 'Nashville'. Correct 98. '37777'). The TEAM_ID value for the Tiger team is 5960. 37777. Which statement should you use? Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1.INSERT VALUES INTO customers (3178 J. INSERT INTO customers VALUES '3178' 'J. .2) You need to increase the salary of each player for all players on the Tiger team by 12. 125 WHERE team_id = 5960.125 WHERE team_id = 5960.125) WHERE team_id = 5960. UPDATE players SET salary = salary * 1.UPDATE players SET salary = salary * . Correct 99. (*) UPDATE players (salary) VALUES(salary * 1. 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 . You need to update the expiration date of products manufactured before June 30th . 100. 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. You need to delete a record in the EMPLOYEES table for Tim Jones. Correct . DELETE * FROM employees WHERE id_num = 348. DELETE 'jones' FROM employees. whose unique employee identification number is 348. (*) DELETE FROM employees WHERE lname = jones. Which three statements about functions are true? (Choose three.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.) Mark for Review (1) Points . The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length. not on numbers. first_name)). In which order are the functions evaluated? Mark for Review (1) Points . (*) The CONCAT function can only be used on character strings. (*) The ROUND number function rounds a value to a specified decimal place or the nearest whole number.(Choose all correct answers) The SYSDATE function returns the Oracle Server date and time. (*) Correct You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. 5) "ID" FROM employee. 1. 00 You query the database and return the value 40. SUBSTR.00 857689 HEEL 85940 11. Which script did you use? Mark for Review .00 809090 LOAFER 89098 10.00 890890 LOAFER 89789 14. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 758960 SANDAL 86979 11.00 869506 SANDAL 89690 15. LOWER (*) Correct 4. SUBSTR. CONCAT. LOWER CONCAT. CONCAT. CONCAT LOWER.00 968950 SANDAL 85909 10.LOWER. SUBSTR SUBSTR. 2. SELECT INSTR(category.2) FROM styles WHERE style_id = 895840. (*) SELECT SUBSTR(category.2) FROM styles WHERE style_id = 895840.2) FROM styles WHERE style_id = 895840. SELECT SUBSTR(category. -2. Correct . -2. 2.2) FROM styles WHERE style_id = 758960.(1) Points SELECT INSTR(category. You issue this SQL statement: SELECT INSTR ('organizational sales'. Which value is returned by this command? Mark for Review (1) Points 1 2 13 (*) 17 Correct 6. 'al') FROM dual. Which function should you use? Mark for Review (1) Points . You need to display the number of characters in each customer's last name. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value.LENGTH (*) LPAD COUNT SUBSTR Correct 7. '$')SALARY FROM employees. LPAD(salary. 15. The last name and the format of the salary limited to 15 digits to the left of the decimal and the column labeled SALARY. . What will the following SQL statemtent display? SELECT last_name. size of 15 and the column labeled SALARY. " Correct .25 1300 (*) .248. What value does this statement produce? Mark for Review (1) Points 1200 1282 1282. -2) FROM dual. You issue this SQL statement: SELECT ROUND (1282. leftpadded with the $ and the column labeled SALARY.The last name and salary for all employees with the format of the salary 15 characters long. (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. Which comparison operator retrieves a list of values? Mark for Review (1) Points IN (*) LIKE . 2) Which value is returned? Mark for Review (1) Points 1 (*) 2 25 0 Correct 10.Correct 9. Evaluate this function: MOD (25. IS NULL Incorrect.BETWEEN. 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.... Which function should you use? Mark for Review (1) Points . Refer to Section 1 Lesson 1 11. You need to display the number of months between today's date and each employee's hiredate.IN.. ROUND BETWEEN ADD_MONTHS MONTHS_BETWEEN (*) Correct 13. Refer to Section 1 . 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. 14. Evaluate this SELECT statement: SELECT SYSDATE + 30 FROM dual. Which value is returned by the query? Mark for Review (1) Points . 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. 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.900. (*) SELECT TO_CHAR(price. "$99. '$99.990. Refer to Section 1 16.99') FROM product.900.99") FROM product. Which SQL Statement should you use to display the prices in this format: "$00.30"? Mark for Review (1) Points SELECT TO_CHAR(price.900. SELECT TO_NUMBER(price. SELECT TO_CHAR(price.99') FROM product. '$99. '$99.99') FROM product. Correct . Incorrect. Each employee's salary must be displayed in the following format: $000. All Human Resources data is stored in a table named EMPLOYEES. 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.17. Refer to Section 2 18.00. You have been asked to create a report that displays each employee's name and salary. 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: .000. 2000 Which SELECT statement could you use? Mark for Review (1) Points SELECT TO_CHAR(hire_date. ' YYYY') FROM employees. Month DD. ' YYYY') FROM employees. SELECT TO_CHAR(hire_date. YYYY') FROM employees. (*) SELECT hire_date(TO_CHAR 'Month DD'. SELECT TO_CHAR(hire_date. 'Month DD'.January 28. YYYY) FROM employees. 'Month DD. . ) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. Refer to Section 2 19.Incorrect. Refer to Section 2 20. (*) Number functions can return number or character values. Incorrect. 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. Not all date functions return date values. Which two statements concerning SQL functions are true? (Choose two. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2 (25) . SELECT TO_NUM(salary.999. '$999. Which script should you use to display the salaries in format: "$45. '$999.00"? Mark for Review (1) Points SELECT TO_CHAR(salary. (*) .999') FROM employees.00') FROM employees. '$999. SELECT TO_CHAR(salary. '$999.000. SELECT TO_NUM(salary.999.00') FROM employees.990.99') FROM employees.FIRST_NAME VARCHAR2 (25) SALARY NUMBER(6) You need to create a report to display the salaries of all employees. Which of the following General Functions will return the first non-null expression in the expression list? Mark for Review (1) Points NVL NVL2 . If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001.Incorrect. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 Correct 22. Refer to Section 2 21. SELECT TO_NUMBER(tuition_balance. SELECT tuition_balance + housing_balance FROM student_accounts. TO_NUMBER (housing_balance. 0) "Balance Due" FROM student_accounts. tutition_balance + housing_balance "Balance Due" .NULLIF COALESCE (*) Correct 23. NVL (housing_balance). When executed. 0). 0). tuition_balance + housing_balance "Balance Due" FROM student_accounts. (*) SELECT NVL(tuition_balance. 0). 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. NVL. can be used with group functions to replace null values. and COALESCE can be used with group functions to replace null values. but not NVL2. Correct 25. but not NVL and NVL2. NVL and COALESCE. (*) COALESCE. Incorrect.FROM student_accounts. how many join conditions are needed in the WHERE clause? Mark for Review (1) Points 0 . can be used with group functions to replace null values. but not COALESCE. When joining 3 tables in a SELECT statement. can be used with group functions to replace null values. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. Refer to Section 2 24. NVL2. 1 2 (*) 3 Correct 26. SELECT last_name. salary FROM employees WHERE salary > 25000 AND dept_id = 10.000 per year. salary FROM employees WHERE salary = 25000 AND dept_id = 10. SELECT last_name. first_name. You need to create a report that lists all employees in the Sales department who do not earn $25. first_name. salary FROM employees . Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT last_name. first_name. WHERE salary <= 25000 AND dept_id = 10. (*) Correct 27. the company and the total sales? . first_name. 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. SELECT last_name. salary FROM employees WHERE salary != 25000 AND dept_id = 10. company.total_sales FROM customers c.cust_id (+). sales s WHERE c.cust_id = s.cust_id = s. SELECT cust_id.cust_id. .cust_id = s.total_sales FROM customers c.cust_id. c.company. sales s WHERE c. sales s WHERE c. s. SELECT c.Mark for Review (1) Points SELECT c. sales WHERE cust_id = cust_id.company.cust_id.cust_id. c. s. total_sales FROM customers. total_sales FROM customers c. company. (*) SELECT cust_id. SELECT fname. (*) SELECT e.lname.emp_id AND revenue >= 100000.lname.sales FROM employees e.sales FROM employees.emp_id = s.000 in revenue. e. e. s. s. sales s WHERE e.emp_id = s. .emp_id AND revenue > 100000.emp_id AND revenue > 100000.fname. You want to identify the sales representatives who have generated at least $100. sales s WHERE e. lname. sales s WHERE e. sales WHERE e.emp_id = s. Which query should you issue? Mark for Review (1) Points SELECT e. s. e.emp_id = s.lname.fname.sales FROM employees e.fname.emp_id AND revenue >= 100000. sales Q FROM employees e. Your have two tables named EMPLOYEES and SALES. SELECT e.Correct 28. 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. Which statement about the join syntax of a SELECT statement is true? Mark for Review (1) Points The ON keyword must be included. Refer to Section 30. The JOIN keyword must be included. 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. t. Evaluate this SELECT statement: SELECT p.The FROM clause represents the join criteria.player_id.last_name. (*) Incorrect. or LEFT keyword must be included. Correct 32. The FULL. m. The OR operator cannot be used to link outer join conditions. m. Refer to Section 3 31.first_name. (*) Outer joins are always evaluated before other types of joins in the query. RIGHT. Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. The WHERE clause represents the join criteria.team_name FROM player p . LEFT OUTER JOIN player m ON (p.player_id) LEFT OUTER JOIN team t ON (p.team_id). 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 = . 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.manager_id = m.team_id = t. Which statement about a natural join is true? Mark for Review (1) Points Columns with the same names must have identical data types.AND. Refer to Section 4 35... Incorrect..BETWEEN. and IN IN and = Incorrect. You need to join all the rows in the EMPLOYEE table to all the rows in the EMP_REFERENCE table. Columns with the same names cannot be included in the SELECT list of the query. Which type of join should you create? Mark for Review (1) Points An equijoin .. (*) Columns with the same names must have compatible data types. Refer to Section 3 34. Columns with the same names must have the same precision and datatype. 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 .A cross join (*) An inner join A full outer join Incorrect. 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. Refer to Section 4 36. 37. A join condition that includes the (+) on the left hand side. 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 that joins a table to itself . custid varchar2(5) references customers (custid)). city varchar2(20). You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in sequence: CREATE TABLE customers (custid varchar2(5). state varchar2(30). total number(15). Refer to Section 4 39.Incorrect. orderdate date. You have been instructed to compile a report to present the information about orders placed by customers who reside in Nashville . phone varchar2(20). companyname varchar2(30). constraint pk_customers_01 primary key (custid)). CREATE TABLE orders (orderid varchar2(5) constraint pk_orders_01 primary key. Which query should you issue to achieve the desired results? Mark for Review (1) Points . address varchar2(30). contactname varchar2(30). companyname FROM customers WHERE city = 'Nashville'. SELECT orderid. total FROM orders WHERE city = 'Nashville'. total FROM orders o JOIN customers c ON o. orderdate.SELECT custid.custid = c. orderdate.custid WHERE city = 'Nashville'. Correct . SELECT orderid. orderdate. (*) SELECT orderid. total FROM orders o NATURAL JOIN customers c ON o.custid WHERE city = 'Nashville'.custid = c. 2) SALES_ORDER ORDER_ID NUMBER NOT NULL.40. 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. 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) . Below find the structure of the CUSTOMERS and SALES_ORDER tables: CUSTOMERS CUSTOMER_ID NUMBER NOT NULL. customer_name FROM customers c.customer_id. .customer_name FROM customers c.customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c. Which statement could you use? Mark for Review (1) Points SELECT c.customer_id = s. sales_order s WHERE c.customer_id = s. SELECT c.customer_name FROM customers c WHERE c.customer_id(+).You need to create a report that displays customers without a sales order. SELECT c.customer_id not in (SELECT s.customer_id).customer_id FROM sales_order s). sales_order s WHERE c. (*) SELECT c.customer_id (+) = s. Refer to Section 4 41.last_name. e. d.department_id.department_name FROM employees e LEFT OUTER JOIN departments d ON (e. (*) SELECT e.department_id.department_id. d.department_id = d. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e. SELECT e. d. Which query will retrieve all the rows in the EMPLOYEES table.Incorrect.department_name FROM employees e NATURAL JOIN departments d. e.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e. SELECT e.last_name.department_id. d.department_id).last_name.department_name FROM employees e .department_id = d.department_id). e. e.last_name. JOIN departments d USING (e. Refer to Section 4 43. Incorrect. 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.department_id = d. Refer to Section 4 42. What should be included in a SELECT statement to return NULL values from all tables? Mark for Review (1) Points natural joins .department_id). left outer joins full outer joins (*) right outer joins Incorrect. Refer to Section 4 44. Evaluate this SELECT statement: . Refer to Section 5 45. 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. The highest salary in each department. The employee with the highest salary for each department. Which values are displayed? Mark for Review (1) Points The highest salary for all employees.SELECT MAX(salary). dept_id FROM employee GROUP BY dept_id. (*) Group functions can only be used in a SELECT list. Refer to Section 5 46. . Incorrect. Which statement about group functions is true? Mark for Review (1) Points Group functions ignore null values. (*) The employees with the highest salaries. What is the best explanation as to why this SQL statement will NOT execute? SELECT department_id "Department". Incorrect. Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. Incorrect. The department id is not listed in the departments table. AVG (salary)"Average" FROM employees GROUP BY Department. You cannot use a column alias in the GROUP BY clause. A query that includes a group function in the SELECT list must include a GROUP BY clause. Refer to Section 5 47. Refer to Section 5 . (*) The GROUP BY clause must have something to GROUP.Group functions can be used in a WHERE clause. SUM.00 89453485 8549038 15-FEB-03 INTEREST 596. 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.48.00 You need to determine the average payment amount made by each customer in January. The AVG. Which SELECT statement should you use? Mark for Review . February and March of 2003. 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 85490345 5489304 20-MAR-03 BASIC 568. (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'. MAR). FEB. SELECT AVG(payment_amount) FROM payment WHERE TO_CHAR(payment_date) IN (JAN. Correct . 2) Which two clauses represent valid uses of aggregate functions for this table? Mark for Review (1) Points . The VENDORS table contains these columns: VENDOR_ID NUMBER Primary Key NAME VARCHAR2(30) LOCATION_ID NUMBER ORDER_DT DATE ORDER_AMOUNT NUMBER(8. You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. Refer to Section 5 51. Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE Incorrect.50. 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 (*) .(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. Which group function will you use? Mark for Review (1) Points AVG (*) MEAN MEDIAN AVERAGE Correct 54. Refer to Section 5 53. You need to calculate the average salary of employees in each department.Incorrect. number and date data types? (Choose more than one answer) Mark for Review (1) Points (Choose all correct answers) SUM . Which group functions below act on character. 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.MAX (*) MIN (*) AVG COUNT (*) Correct 55. . 00 890890 LOAFER 89789 14. Refer to Section 5 56. (*) Incorrect. The values in the PROD_PRICE column and the PROD_QTY column are averaged together. Only the average quantity of the products is returned.00 869506 SANDAL 89690 15.00 758960 SANDAL 86979 .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. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 857689 HEEL 85940 11. An error occurs.00 809090 LOAFER 89098 10.00 968950 SANDAL 85909 10. 05 .10 768385 862459 849869 5. Which value is displayed? Mark for Review (1) Points 0 6 7 (*) The statement will NOT execute successfully.60 0. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT 890898 847589 848399 8.You issue this SELECT statement: SELECT COUNT(category) FROM styles.99 0. Incorrect. Refer to Section 5 57. SELECT AVG(discount) FROM line_item. Incorrect. (*) SELECT SUM(discount) FROM line_item. Which SQL statement did you execute? Mark for Review (1) Points SELECT COUNT(discount) FROM line_item. SELECT COUNT(*) FROM line_item.867950 985490 945809 5.60 954039 439203 438925 5. Group functions can avoid computations involving duplicate values by including which keyword? Mark for Review (1) Points NULL .25 0.50 You query the LINE_ITEM table and a value of 5 is returned. Refer to Section 5 58.15 543949 349302 453235 4. (*) The number of unique PRODUCT_IDs in the table is displayed. Evaluate this SELECT statement: SELECT COUNT(*) FROM products. An error occurs because no WHERE clause is included in the SELECT statement. .DISTINCT (*) SELECT UNLIKE Incorrect. Refer to Section 5 59. An error occurs due to an error in the SELECT clause. Which statement is true? Mark for Review (1) Points The number of rows in the table is displayed. 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. 0)) (*) HAVING MAX(salary) > 10000 (*) . Refer to Section 5 60.Incorrect.) Mark for Review (1) Points (Choose all correct answers) ORDER BY AVG(salary) GROUP BY MAX(salary) (*) SELECT AVG(NVL(salary. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. COUNT(DISTINCT type) FROM manufacturer. 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. (*) SELECT location_id.WHERE hire_date > AVG(hire_date) Incorrect. . Which SELECT statement should you use? Mark for Review (1) Points SELECT location_id. SELECT 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 . COUNT(type) FROM manufacturer GROUP BY location_id. HAVING GROUP BY WHERE ORDER BY SELECT FROM WHERE GROUP BY HAVING ORDER BY (*) SELECT FROM WHERE HAVING ORDER BY GROUP BY Correct . prod_cat . MIN (prod_price) FROM products GROUP BY prod_cat. SELECT prod_cat. 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. (*) SELECT MIN (prod_price). 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.63. name . id_number. prod_cat. SELECT prod_price. name. department_id. MIN (prod_cat) FROM products GROUP BY prod_cat. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id.2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. The EMPLOYEES table contains these columns: ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER SALARY NUMBER (7. Correct 64.FROM products GROUP BY MIN (prod_price). The HIRE_DATE column is NOT included in the GROUP BY clause.ORDER BY hire_date. Which clause of the SELECT statement contains a syntax error? Mark for Review . Evaluate this SELECT statement: SELECT SUM(salary). department_name FROM employee WHERE dept_id = 1 GROUP BY department. The SALARY column is NOT included in the GROUP BY clause. dept_id. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing. (*) Correct 65. The WHERE clause contains a syntax error. 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.(1) Points SELECT FROM WHERE GROUP BY (*) Incorrect. The PLAYERS and TEAMS tables contain these columns: PLAYERS PLAYER_ID NUMBER NOT NULL. Primary Key TEAM_NAME VARCHAR2 (25) . Refer to Section 66. position) = 'PITCHER' GROUP BY t.You need to create a report that lists the names of each team with more than five pitchers. teams t ON (p.team_name. Which SELECT statement will produce the desired result? Mark for Review (1) Points SELECT t.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5.team_id = t.position) = 'PITCHER' . teams t ON (p.team_name HAVING COUNT(p.team_id) WHERE UPPER(p.team_name.team_id) WHERE UPPER(p. COUNT(p. SELECT t.player_id) FROM players p.player_id) FROM players p JOIN teams t ON (p.team_id) WHERE UPPER(p.team_id) WHERE UPPER(p.position) = 'PITCHER' GROUP BY t.team_name. COUNT(p.team_id = t.player_id) FROM players p.team_id = t. SELECT t. SELECT t.player_id) FROM players JOIN teams t ON (p.team_name.player_id) > 5. COUNT(p. COUNT(p.team_name.team_id = t. You must use the HAVING clause with the GROUP BY clause. (*) You can use a column alias in a GROUP BY clause. rows are not sorted when a GROUP BY clause is used.GROUP BY t. 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. By default. Refer to Section 6 68.player_id) > 5. Using a subquery in which clause will return a syntax error? Mark for Review (1) Points WHERE .team_name HAVING COUNT(p. Incorrect. (*) Incorrect. Refer to Section 6 67. you use should a WHERE clause. 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. Refer to Section 6 69. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns: . (*) Incorrect.FROM HAVING There are no places you cannot place subqueries. Which two SQL statements correctly use subqueries? (Choose two.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.) Mark for Review (1) Points (Choose all correct answers) SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments). (*) SELECT * . Incorrect. The EMPLOYEES and ORDERS tables contain these columns: . SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id). (*) 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).FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963). Refer to Section 6 71. 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'. total FROM ORDERS WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin'. 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'. SELECT order_id. emp_id.SELECT (SELECT emp_id FROM employees WHERE lname = 'Franklin') AND order_id. Examine the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8. SELECT order_id.2) . (*) Correct 72. total FROM ORDERS WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01'. You need to display all the orders that were placed on a certain date. You need to display each date that a customer placed an order.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. Refer to Section 6 . You need to display all the orders that were placed on the same day as order number 25950. (*) Incorrect.OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). 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'). However.73. SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id FROM supervisors . what will the outer query return? Mark for Review (1) Points no rows (*) all the rows in the table a null value . (*) Incorrect. If a single-row subquery returns a null value and uses the equality comparison operator. Refer to Section 6 74. SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter').WHERE last_name = 'Carter'). 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 (*) . 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.an error Incorrect. Refer to Section 6 76. Refer to Section 6 75. 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).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. SELECT description FROM d_types WHERE code <> ALL (SELECT type_code FROM d_songs). No rows would be returned by the outer query. Only the rows with CUSTOMER_ID values equal to null would be selected.All of the above. Evaluate this SELECT statement: SELECT customer_id.00). Refer to Section 6 78. . What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. (*) Incorrect. (*) All the rows in the table would be selected. AND. and > Incorrect. =. 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.. and ALL (*) LIKE BETWEEN... Refer to Section 6 80. <.. ANY. 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 (*) . Refer to Section 6 79.Incorrect. Refer 82.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. 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. (*) . 000. The data returned may or may not be correct.No rows will be selected. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). All the rows will be selected. Incorrect. Only employees who earn less than $50. Evaluate this SQL statement: SELECT employee_id. . Refer to Section 6 83. Which values will be displayed? Mark for Review (1) Points Only employees who earn more than $30.000. last_name. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859. payment_type FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_amount = 596.00 89453485 8549038 15-FEB-03 INTEREST 596.000.00 85490345 5489304 20-MAR-03 BASIC 568.000.00 This statement fails when executed: SELECT customer_id.00 OR payment_date = '20-MAR-2003').000 and more than $50.000. (*) Correct 84. All employees who work in a department with employees who earn more than $30. but less than $50.All employees who work in a department with employees who earn more than $30. . Refer to Section 6 85. Incorrect. Change the comparison operator to a single-row operator. Mark for Review (1) Points Single rows contain multiple values and a logical operator is used. What is wrong with the following query? SELECT employee_id.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. last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). . 00 89453485 8549038 15-FEB-03 INTEREST 596. it will run without problems. Incorrect. payment_amount FROM payment WHERE payment_id = (SELECT payment_id FROM payment . Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859. Nothing.00 85490345 5489304 20-MAR-03 BASIC 568. customer_id. Refer to Section 6 86. (*) Subquery references the wrong table in the WHERE clause.00 This statement fails when executed: SELECT payment_date.Subquery returns more than one row and single row comparison operator is used. Change the outer query WHERE clause to 'WHERE payment_id IN'. Incorrect.00). 100. 'Public Relations'. manager_id. department_name.WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500. The following SQL statement will execute which of the following? INSERT INTO departments (department_id. Which change could correct the problem? Mark for Review (1) Points Remove the subquery WHERE clause. Assume all the column names are correct. Mark for Review (1) Points 100 will be inserted into the department_id column . Remove the single quotes around the date value in the inner query WHERE clause. Refer to Section 6 87. (*) Include the PAYMENT_ID column in the select list of the outer query. location_id) VALUES (70. 1700). Which DML statement should you use? Mark for Review (1) Points UPDATE INSERT (*) DELETE CREATE Incorrect. Refer 89. The PRODUCTS table contains these columns: . Refer to Section 7 88.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. You need to add a row to an existing table. 'Cable'. Incorrect. 700). INSERT INTO products(product_id. INSERT INTO products(product_id. supplier_id VALUES (2958. (*) INSERT INTO products VALUES (2958. Refer to Section 7 90. 8690. 'Cable'). 'Cable'. product_name.09. 7. SYSDATE). 'Cable'.04. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table.PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. What could you use in the INSERT statement to accomplish this task? Mark for Review . 8690.09. 4.04. 7. SYSDATE). 4. product_name) VALUES (2958.2) COST NUMBER (5. 8690.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. 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 . Her new last name is Cooper. and she has requested that you update her name in the employee database. has informed you that she was recently married. Janet Roper. One of the sales representatives. Janet is the only person with the last name of Roper that is employed by the company.(1) Points an ON clause a SET clause a subquery (*) a function Correct 91. UPDATE employees SET lname = 'roper' WHERE lname = 'cooper'. Refer to Section 7 . Incorrect.(1) Points UPDATE employees SET lname = 'cooper' WHERE lname = 'roper'. (*) UPDATE employees lname = 'cooper' WHERE lname = 'roper'. UPDATE employees SET cooper = 'lname' WHERE lname = 'roper'. You need to remove a row from the EMPLOYEE table.2) MANAGERS . 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.92. 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.2) SALARY NUMBER(9. their manager. and their team name for all teams with a id value greater than 5000 Correct .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. Currently. all employees in department 10 have the same salary value.94. UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898). 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) 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. Which statement should you execute? Mark for Review (1) Points UPDATE employee SET salary = SELECT salary FROM employee WHERE emp_id = 89898. .2) BONUS NUMBER(9. Incorrect. (*) UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10). (*) The statement deletes the CUSTOMER column.UPDATE employee SET salary = (SELECT salary FROM employee WHERE emp_id = 89898) WHERE dept = 10. Which statement is true? Mark for Review (1) Points The statement deletes all the rows from the CUSTOMER table. Evaluate this statement: DELETE FROM customer. Refer to Section 7 95. . The statement deletes the first row in the CUSTOMERS table. The statement removes the structure of the CUSTOMER table from the database. 2) You need to increase the salary of each player for all players on the Tiger team by 12.Incorrect.5 percent. what is the result? Mark for Review (1) Points All rows are deleted from the table. An error message is displayed indicating incorrect syntax. The statement will not execute. Nothing. The TEAM_ID value for the Tiger team is 5960. 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. When the WHERE clause is missing in a DELETE statement. Which statement should you use? . (*) The table is removed from the database. Correct 97. Refer to Section 7 96. 125 WHERE team_id = 5960. (*) UPDATE players (salary) VALUES(salary * 1. UPDATE players SET salary = salary * .125. whose unique employee identification number is 348.Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1.125) WHERE team_id = 5960.125 WHERE team_id = 5960. Correct 98. You need to delete a record in the EMPLOYEES table for Tim Jones. UPDATE players SET salary = salary * 1. 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 . 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 . (*) DELETE FROM employees WHERE lname = jones.DELETE FROM employees WHERE id_num = 348. DELETE * FROM employees WHERE id_num = 348. You need to update the expiration date of products manufactured before June 30th . DELETE 'jones' FROM employees. Correct 99. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table using one UPDATE statement.100.) Mark for Review (1) Points (Choose all correct answers) . Which three statements about functions are true? (Choose three. 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. (*) Correct 2.00 809090 LOAFER 89098 10.00 857689 HEEL 85940 11. (*) The CONCAT function can only be used on character strings.00 758960 SANDAL 86979 12.00 869506 SANDAL 89690 15.00 . not on numbers. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. (*) The ROUND number function rounds a value to a specified decimal place or the nearest whole number. The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length.00 890890 LOAFER 89789 14.The SYSDATE function returns the Oracle Server date and time.00 968950 SANDAL 85909 10. You query the database and return the value 79. Which script did you use? Mark for Review (1) Points SELECT INSTR(category.2) FROM styles WHERE style_id = 895840. SELECT INSTR(category. (*) . -2. SELECT SUBSTR(category. SELECT SUBSTR(category. -2. 2.2) FROM styles WHERE style_id = 895840.2) FROM styles WHERE style_id = 895840.2) FROM styles WHERE style_id = 758960. 2. Which character function should you use? Mark for Review (1) Points INSTR . You need to return a portion of each employee's last name. beginning with the first character up to the fifth character.Correct 3. Which function should you use? Mark for Review (1) Points LENGTH (*) LPAD COUNT SUBSTR Correct 4. You need to display the number of characters in each customer's last name. number. and date column values? Mark for Review (1) Points CONCAT. TRUNC. and ADD_MONTHS Incorrect.TRUNC SUBSTR (*) CONCAT Correct 5. Refer to Section 1 . and TRIM (*) UPPER. RPAD. Which functions can be used to manipulate character. TRUNC. and INITCAP ROUND. and MOD ROUND. LOWER. In which order are the functions evaluated? Mark for Review (1) Points LOWER. SUBSTR SUBSTR. LOWER CONCAT. CONCAT. 5) "ID" FROM employee. You query the database with this SQL statement: . 1. SUBSTR. LOWER (*) Correct 7.6. first_name)). SUBSTR. CONCAT. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. CONCAT LOWER. Which function will be evaluated first? Mark for Review (1) Points CONCAT SUBSTR LOWER (*) All three will be evaluated simultaneously. (SUBSTR(LOWER(first_name). 4))) "Default Password" FROM employees.SELECT CONCAT(last_name. Correct Section 1 Lesson 2 (Answer all questions in this section) . 2) Which value is returned? Mark for Review (1) Points 1 (*) 2 25 0 Correct 9.IN. Which comparison operator retrieves a list of values? Mark for Review (1) Points IN (*) LIKE BETWEEN.. Evaluate this function: MOD (25....8. IS NULL . 'MONTH') FROM employees. 'MI') FROM employees. SELECT ROUND(hire_date. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review (1) Points SELECT TRUNC(hire_date. SELECT TRUNC(hire_date. 'MON') FROM employees.Correct 10. 'MONTH') FROM employees. . (*) SELECT ROUND(hire_date. hire_date) + 10*8 FROM employees. SELECT (SYSDATE .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 (hire_date . You need to display the number of months between today's date and each employee's hiredate. Incorrect.SYSDATE) + TO_DATE('25-JUN-02') FROM employees. Which function should you use? Mark for Review (1) Points ROUND BETWEEN ADD_MONTHS MONTHS_BETWEEN (*) .SELECT SYSDATE . Refer to Section 1 12.TO_DATE('25-JUN-02') + hire_date FROM employees. total FROM orders WHERE order_date IN ( 01-jan-02 . (*) . SELECT orderid. Which query should you issue? Mark for Review (1) Points SELECT orderid. SELECT orderid. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC. You want to create a report that displays all orders and their amounts that were placed during the month of January. total FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' ORDER BY total DESC.Correct 13. 31-jan-02 ) ORDER BY total. You want the orders with the highest amounts to appear first. 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 . 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.15. The values returned by this SELECT statement will be of which data type? Mark for Review (1) Points DATE (*) NUMBER DATETIME . 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 . 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.00.000. Each employee's salary must be displayed in the following format: $000.INTEGER Correct Section 2 Lesson 1 (Answer all questions in this section) 16. 17. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 Correct 18. The TO_CHAR function can be used to remove text from column data that will be returned by the database. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001. . 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. but can return multiple values. Incorrect.) Mark for Review . (*) The TO_CHAR function can only be used on DATE columns. Single row functions can be nested.The TO_CHAR function can be used to display dates and numbers according to formatting conventions that are supported by Oracle. (*) Single row functions return one or more results per row. Which three statements concerning explicit data type conversions are true? (Choose three. Incorrect. Single row functions cannot modify a data type. Refer to Section 2 20. 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. (*) Correct Page 2 of 10 Section 2 Lesson 1 (Answer all questions in this section) 21. (*) 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. The EMPLOYEES table contains these columns: . Use the TO_DATE function to convert a character string to a date value.(1) Points (Choose all correct answers) Use the TO_NUMBER function to convert a number to a character string. YYYY) FROM employees. Month DD. 2000 Which SELECT statement could you use? Mark for Review (1) Points SELECT TO_CHAR(hire_date.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. 'Month DD. (*) . YYYY') FROM employees. SELECT TO_CHAR(hire_date. NVL2. but not NVL2. Incorrect. but not COALESCE. NVL.SELECT hire_date(TO_CHAR 'Month DD'. Refer to Section 2 Section 2 Lesson 2 (Answer all questions in this section) 22. SELECT TO_CHAR(hire_date. NVL and COALESCE. 'Month DD'. ' YYYY') FROM employees. ' YYYY') FROM employees. (*) . Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. and COALESCE can be used with group functions to replace null values. can be used with group functions to replace null values. can be used with group functions to replace null values. 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. Correct 23. which statement displays a zero if the TUITION_BALANCE value is zero and the HOUSING_BALANCE value is null? Mark for Review (1) Points . When executed. but not NVL and NVL2. Refer to Section 2 24.COALESCE. can be used with group functions to replace null values. Correct . SELECT tuition_balance + housing_balance FROM student_accounts. 0). tuition_balance + housing_balance "Balance Due" FROM student_accounts. tutition_balance + housing_balance "Balance Due" FROM student_accounts. 0). 0). NVL (housing_balance). (*) SELECT NVL(tuition_balance. TO_NUMBER (housing_balance. 0) "Balance Due" FROM student_accounts.SELECT NVL (tuition_balance + housing_balance. SELECT TO_NUMBER(tuition_balance. .department_id AND employees. d. departments d WHERE e. e.department_id = d.last_name.department_id = d.department_id AND employees. Which clause contains a syntax error? Mark for Review (1) Points SELECT e. d. Evaluate this SQL statement: SELECT e.first_name. e.first_name.employee_id. departments d WHERE e.department_name FROM employees e.department_id > 5000 (*) ORDER BY 4.last_name.Section 3 Lesson 2 (Answer all questions in this section) 25.employee_id. e.department_id > 5000 ORDER BY 4. e.department_name FROM employees e. Refer to Section 3 26. You need to create a report that lists all employees in department 10 (Sales) whose salary is not equal to $25. first_name.000 per year. salary FROM employees WHERE salary > 25000 AND department_id = 10. Refer to Section 3 27.Incorrect. 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. . Which query should you issue to accomplish this task? Mark for Review (1) Points SELECT last_name. first_name. SELECT last_name. first_name. SELECT last_name. salary FROM employees WHERE salary <= 25000 AND department_id = 10. salary FROM employees WHERE salary = 25000 AND department_id = 10. first_name. salary FROM employees WHERE salary != 25000 AND department_id = 10. (*) Correct 28.SELECT last_name. Which statement about the join syntax of an Oracle Proprietary join syntax SELECT statement is true? Mark for Review (1) Points . 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? . The FROM clause represents the join criteria. The JOIN keyword must be included. (*) Correct 29. The WHERE clause represents the join criteria.The ON keyword must be included. total_sales FROM customers c.company.cust_id = s. (*) SELECT cust_id. SELECT c. c. s. sales WHERE cust_id = cust_id.company. SELECT cust_id.total_sales FROM customers c. total_sales FROM customers c. sales s WHERE c. company.cust_id = s.cust_id (+).Mark for Review (1) Points SELECT c.cust_id = s. s. company.cust_id. . total_sales FROM customers. sales s WHERE c. c. sales s WHERE c.cust_id.cust_id.cust_id. employee_id AND revenue > 100000.Correct 30. sales Q FROM employees e. Your have two tables named EMPLOYEES and SALES. in revenue.employee_id AND revenue >= 100000.employee_id = s.last_name.first_name. You want to identify the sales representatives who have generated $100.first_name. last_name.employee_id = s. e. sales WHERE e. SELECT e. sales s WHERE e. Which query should you issue? Mark for Review (1) Points SELECT e. s.sales FROM employees e. e. or more.sales FROM employees.000. (*) SELECT e.last_name. sales s WHERE e. sales s .sales FROM employees e. e. s.employee_id AND revenue >= 100000.first_name. SELECT first_name. s.last_name.employee_id = s. Which type of join should you use to display the data? Mark for Review (1) Points natural join self-join outer join (*) equijoin .employee_id AND revenue > 100000. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you need to display.WHERE e. The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of the ORDERS table.employee_id = s. Correct Page 3 of 10 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 = (*) . Using Oracle Proprietary join syntax. Correct 33. The FULL. RIGHT. or LEFT keyword must be included. (*) Outer joins are always evaluated before other types of joins in the query. The OR operator cannot be used to link outer join conditions.Correct 32. Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. .. department_name FROM employees CROSS JOIN departments.. The following SQL statement will produce what output? SELECT last_name.. and IN IN and = Correct Section 4 Lesson 2 (Answer all questions in this section) 34.AND.OR and = BETWEEN. Mark for Review (1) Points The missing rows from the join condition.. datatype and precision. A Cartesian product between the two tables.The last_name and department name from the employee table. You need to join two tables that have two columns with the same name. 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 . Correct 35. (*) A cross referenced result omitting similar fields from the two tables. 36. You need to join all the rows in the EMPLOYEES table to all the rows in the EMP_REFERENCES table. 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. (*) . 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. Below find the structure of the CUSTOMERS and SALES_ORDER tables: CUSTOMERS CUSTOMER_ID NUMBER NOT NULL. Refer to Section 4 38. The CUSTOMER and ORDER tables have no columns with identical names. CUST_ID. The CUSTOMER and ORDER tables have a corresponding column. The CUST_ID column in the ORDER table contains null values that need to be displayed. Incorrect. 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) .The ORDER table contains a column that has a referential constraint to a column in the PRODUCT table. .customer_id not in (SELECT s.customer_name FROM customers c.customer_id(+).customer_name FROM customers c WHERE c.customer_id FROM sales_order s). sales_order s WHERE c. Primary Key CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table ORDER_DT DATE ORDER_AMT NUMBER (7.customer_id = s.2) SHIP_METHOD VARCHAR2 (5) You need to create a report that displays customers without a sales order.FAX VARCHAR2 (20) CREDIT_LIMIT NUMBER(7. (*) SELECT c. Which statement could you use? Mark for Review (1) Points SELECT c.2) SALES_ORDER ORDER_ID NUMBER NOT NULL. customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c. Correct 39.customer_name FROM customers c.customer_id). sales_order s WHERE c.customer_id = s.customer_id (+) = s. . SELECT c. A join condition that includes the (+) on the left hand side. 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.SELECT c.customer_id. companyname varchar2(30). address varchar2(30). You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in sequence: CREATE TABLE customers (custid varchar2(5). CREATE TABLE orders (orderid varchar2(5) constraint pk_orders_01 primary key. You have been instructed to compile a report to present the information about orders placed by customers who reside in Nashville . constraint pk_customers_01 primary key (custid)). state varchar2(30). city varchar2(20). total number(15). contactname varchar2(30). orderdate date.A join that joins a table to itself Correct 40. Which query should you issue to achieve the desired results? . phone varchar2(20). custid varchar2(5) references customers (custid)). custid WHERE city = 'Nashville'. orderdate.custid = c. SELECT orderid. . total FROM orders o NATURAL JOIN customers c ON o. (*) SELECT orderid.custid WHERE city = 'Nashville'. total FROM orders o JOIN customers c ON o. orderdate. total FROM orders WHERE city = 'Nashville'. companyname FROM customers WHERE city = 'Nashville'.custid = c.Mark for Review (1) Points SELECT custid. SELECT orderid. orderdate. 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 . orderdate. Which query represents the correct syntax for a left outer join? Mark for Review (1) Points SELECT companyname. orderdate.Correct 42.cust_id. SELECT companyname.cust_id.cust_id. total FROM customers c LEFT OUTER JOIN orders o ON c.cust_id = o.cust_id = o. total FROM customers c LEFT JOIN orders o ON c. total FROM customers c OUTER JOIN orders o ON c. (*) .cust_id = o. orderdate. SELECT companyname. total FROM customers c LEFT OUTER orders o ON c. orderdate.cust_id = o.SELECT companyname.cust_id. 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 . Correct 43. Which values are displayed? Mark for Review (1) Points The earliest hire date in each department.Section 5 Lesson 1 (Answer all questions in this section) 44. department_id FROM employees GROUP BY department_id. Evaluate this SELECT statement: SELECT MIN(hire_date). . The hire dates in the EMPLOYEES table that contain NULL values. (*) The the earliest hire date in the EMPLOYEES table. The latest hire date in the EMPLOYEES table. (*) The last column listed in the GROUP BY clause is the most major grouping. .Correct 45. Correct 46. Group functions can be nested to a depth of? Mark for Review (1) Points three four two (*) Group functions cannot be nested. 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. Correct 47. A GROUP BY clause cannot be used without an ORDER BY clause.The GROUP BY clause can contain an aggregate function. 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 . Which group function should you use to calculate this value? Mark for Review (1) Points AVG (*) SUM COUNT STDDEV .Section 5 Lesson 2 (Answer all questions in this section) 48.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. The CUSTOMERS table contains these columns: CUSTOMER_ID NUMBER(9) FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(9. or SALARY columns? (Choose three. LAST_NAME.2) COMM_PCT NUMBER(4.) Mark for Review (1) Points (Choose all correct answers) MAX (*) SUM AVG MIN (*) .2) HIRE_DATE DATE BONUS NUMBER(7.Correct 49.2) Which three functions could be used with the HIRE_DATE. Refer to Section 5 50. You need to compute the total salary for all employees in department 10.COUNT (*) Incorrect. Which group function will you use? Mark for Review (1) Points MAX SUM (*) VARIANCE COUNT Correct Page 5 of 10 . 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 .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 (Choose all correct answers) SUM MAX (*) MIN (*) AVG .AVG COUNT MAX MIN (*) Correct 53. Refer to Section 5 55. ignore (*) each row. Which group function would you use to display the average price of all products in the PRODUCTS table? Mark for Review (1) Points . Mark for Review (1) Points a row set. include each row. ignore a row set. include Incorrect. Group functions return a value for ________________ and ________________ null values in their computations.COUNT (*) Correct 54. Group functions can avoid computations involving duplicate values by including which keyword? Mark for Review (1) Points NULL DISTINCT (*) .SUM AVG (*) COUNT MAX Correct Section 5 Lesson 3 (Answer all questions in this section) 56. 00 758960 SANDAL 86979 You issue this SELECT statement: SELECT COUNT(category) FROM styles.SELECT UNLIKE Correct 57.00 968950 SANDAL 85909 10.00 869506 SANDAL 89690 15.00 890890 LOAFER 89789 14. Which value is displayed? .00 857689 HEEL 85940 11. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 809090 LOAFER 89098 10. Which results will the query display? Mark for Review (1) Points The number of employees that have a salary less than 30000. Correct 58.Mark for Review (1) Points 0 6 7 (*) The statement will NOT execute successfully. Evaluate this SELECT statement: SELECT COUNT(*) FROM employees WHERE salary > 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. SELECT COUNT (*) FROM products. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for Review (1) Points SELECT COUNT(products). Correct 59.The total of the SALARY column for all employees that have a salary greater than 30000. SELECT COUNT FROM products. (*) SELECT ROWCOUNT FROM products. Correct . 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.Section 6 Lesson 1 (Answer all questions in this section) 60. Which SELECT statement will produce the desired result? Mark for Review (1) Points SELECT t. The PLAYERS and TEAMS tables contain these columns: PLAYERS PLAYER_ID NUMBER NOT NULL.team_id = t. teams t ON (p.team_name.player_id) FROM players p. 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. COUNT(p.team_id) . team_name HAVING COUNT(p. teams t ON (p.position) = 'GOAL KEEPER' GROUP BY t.WHERE UPPER(p. SELECT t. COUNT(p.position) = 'GOAL KEEPER' HAVING COUNT(p.team_name.position) = 'GOAL KEEPER' GROUP BY t. SELECT t.position) = 'GOAL KEEPER' GROUP BY t.team_id = t.team_id) WHERE UPPER(p. COUNT(p. SELECT t.team_name.team_name.player_id) FROM players p JOIN teams t ON (p.player_id) FROM players p.team_id = t.player_id) > 3.team_id) WHERE UPPER(p. (*) Correct .team_name.team_id = t. COUNT(p.player_id) > 3.team_name HAVING COUNT(p.player_id) FROM players JOIN teams t ON (p.player_id) > 3.team_id) WHERE UPPER(p. dept_id FROM employee WHERE status = 'I' GROUP BY dept_id HAVING salary > 30000 ORDER BY 2. mgr_id. (*) The HAVING clause must specify an aggregate function. . Why does this statement return a syntax error? Mark for Review (1) Points MGR_ID must be included in the GROUP BY clause.Page 6 of 10 Section 6 Lesson 1 (Answer all questions in this section) 61. Evaluate this SELECT statement: SELECT COUNT(emp_id). based on a group function? Mark for Review (1) Points HAVING SUM(salary) > 100000 (*) WHERE SUM(salary) > 100000 WHERE salary > 100000 HAVING salary > 100000 . The ORDER BY clause must specify a column name in the EMPLOYEE table. Which SELECT statement clause allows you to restrict the rows returned. manager_id. manager_id FROM employees GROUP BY department_id. Evaluate this SELECT statement: SELECT SUM(salary). Correct 62. department_id.A single query cannot contain a WHERE clause and a HAVING clause. Incorrect. 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. . SELECT prod_cat. 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_cat. Refer to Section 6 63. MIN (prod_price) FROM products GROUP BY prod_price. (*) SELECT MIN (prod_price). Correct 64. MIN (prod_cat) FROM products GROUP BY prod_cat. prod_cat FROM products GROUP BY MIN (prod_price). prod_cat. 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 prod_price. The EMPLOYEES table contains the following columns: EMPLOYEES: .SELECT id_number. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. (*) Correct 65. The HIRE_DATE column is NOT included in the GROUP BY clause. name ORDER BY hire_date. The WHERE clause contains a syntax error. department_id. sorted by departments. id_number. hire_date. name. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing. The SALARY column is NOT included in the GROUP BY clause. You want to write a report that returns the average salary of all employees in the company. 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 BY department. SELECT AVG (salary) FROM employees GROUP BY department. . Correct 66.SELECT AVG salary FROM employees BY department. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. Evaluate this statement: SELECT department_id. Which clauses restricts the result? Choose two. Mark for Review (1) Points (Choose all correct answers) . department_id. Which clause of the SELECT statement contains a syntax error? Mark for Review (1) Points SELECT FROM .SELECT department_id. department_name FROM employees WHERE department_id = 1 GROUP BY department. department_id HAVING AVG(salary) > 35000 (*) Correct 67. Evaluate this SELECT statement: SELECT SUM(salary). AVG(salary) WHERE job_id <> 69879 (*) GROUP BY job_id. 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) . You need to display each date that a customer placed an order.ORDER_DATE DATE TOTAL NUMBER(8. 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 . You need to display all the orders that were placed on a certain date. (*) Correct 69. You need to display all the orders that were placed on the same day as order number 25950.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. up to 5 unlimited Incorrect. 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 . Refer to Section 6 70. Correct 72. Subqueries cannot contain group functions. Which of the following is TRUE regarding the order of subquery execution? Mark for Review (1) Points . (*) Subqueries generally execute last.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 are often used in a WHERE clause to return values for an unknown conditional value. after the main or outer query executes. 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) . You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. However. SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = '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'). you are not sure which supervisor ID belongs to Brad Carter. SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id . FROM supervisors WHERE last_name = 'Carter'). Which statement about the <> operator is true? Mark for Review (1) Points The <> operator is NOT a valid SQL operator. The <> operator returns the same result as the ANY operator in a subquery. SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter'). Refer to Section 6 74. . The <> operator CANNOT be used in a single-row subquery. (*) Incorrect. 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) . DEPARTMENT. (*) Correct 75. Examine the structure of the EMPLOYEE.The <> operator can be used when a single-row subquery returns only one row. 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. (*) . Correct 77. first_name FROM customer WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). (*) . Evaluate this SELECT statement that includes a subquery: SELECT last_name.Single-row operators can be used with both single-row and multiple-row subqueries. The results of the inner query are returned to the outer query. Multiple-row subqueries can be used with both single-row and multiple-row operators. Which statement is true about the given subquery? Mark for Review (1) Points The outer query executes before the nested subquery. Multiple-row subqueries can only be used in SELECT statements. . and ALL (*) LIKE BETWEEN. Refer to Section 6 78. and > Correct 79. <. =.. Incorrect.AND... which comparison operator(s) can you use? Mark for Review (1) Points IN. Both the inner and outer queries must return a value. ANY. or an error occurs.An error occurs if the either the inner or outer queries do not return a value. You need to create a SELECT statement that contains a multiple-row subquery. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables: EMPLOYEE: . last_name. first_name. department_id) IN (SELECT employee_id.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. new_dept_id FROM depart_hist WHERE old_dept_id = 15) AND new_dept_id = 10. but used to be in department 15. (*) .EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) MANAGER_ID NUMBER(9) SALARY NUMBER(7. Which query should you use? Mark for Review (1) Points SELECT employee_id. department_id FROM employee WHERE (employee_id. SELECT employee_id. department_id FROM employee WHERE (employee_id) IN (SELECT employee_id FROM employee_hist WHERE old_dept_id = 15).SELECT employee_id. first_name. dept_id FROM employee WHERE old_dept_id = 15). department_id FROM employee WHERE (employee_id. department_id) = (SELECT employee_id. SELECT employee_id. last_name. first_name. last_name. department_id) IN (SELECT employee_id. . department_id FROM employee WHERE (employee_id. last_name. first_name. new_dept_id FROM depart_hist WHERE new_dept_id = 15). 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 . What will the following SQL statement display? SELECT department_id. You are looking for Executive information using a subquery.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. last_name. job_id FROM employees WHERE department_id IN . (SELECT department_id FROM departments WHERE department_name = 'Executive'). department name and last name for every employee in the Executive department. 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 (*) . The department ID. last name. job ID from departments for Executive employees. last name. job ID for every employee in the Executive department. last name. The department ID. Mark for Review (1) Points The department ID. department name for every Executive in the employees table. The department ID. (*) Correct 83. 00 89453485 8549038 15-FEB-03 INTEREST 596.00).00 This statement fails when executed: SELECT payment_date.Compare value to every value returned by the subquery Equal to each value in the list Correct 84. payment_amount FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500. Which change could correct the problem? . customer_id. 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 85490345 5489304 20-MAR-03 BASIC 568. Change the outer query WHERE clause to 'WHERE payment_id IN'.Mark for Review (1) Points Remove the subquery WHERE clause. Which multiple-row comparison operator could you use? Mark for Review (1) Points >ANY (*) NOT=ALL IN >IN . Remove the single quotes around the date value in the inner query WHERE clause. (*) Include the PAYMENT_ID column in the select list of the outer query. Correct 85. You need to display all the products that cost more than the maximum cost of every product produced in Japan. 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 <> ALL (SELECT type_code FROM d_songs). All of the above.Correct 86. (*) . SELECT description FROM d_types WHERE code = ANY (SELECT type_code FROM d_songs). date. Refer to Section 7 . then the values must be in the order the columns are specified in the table. Incorrect.Correct Section 7 Lesson 1 (Answer all questions in this section) 87. (*) The VALUES clause in an INSERT statement is optional. and numeric data must be enclosed within single quotes in the VALUES clause. Which statement about the VALUES clause of an INSERT statement is true? Mark for Review (1) Points If no column list is specified. To specify a null value in the VALUES clause. Character. use an empty string (' '). 2) COST NUMBER (5.2) QTY_IN_STOCK NUMBER(4) LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE . The PRODUCTS table contains these columns: PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. 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.88. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. 8690. 4. Mark for Review (1) Points 100 will be inserted into the department_id column . 100. Assume all the column names are correct.09. product_name. 1700). 7. (*) INSERT INTO products VALUES (2958.09. The following SQL statement will execute which of the following? INSERT INTO departments (department_id.04. INSERT INTO products(product_id. 4. 7.Which INSERT statement will execute successfully? Mark for Review (1) Points INSERT INTO products VALUES (2958. 'Cable'. 700). manager_id. 'Cable'. SYSDATE). INSERT INTO products(product_id. Correct 90.04. 'Cable'). 'Cable'. 'Public Relations'. 8690. location_id) VALUES (70. 8690. product_name) VALUES (2958. SYSDATE). supplier_id VALUES (2958. department_name. 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) .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. (*) . Currently. 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.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. Which statement should you execute? Mark for Review (1) Points UPDATE employees SET salary = SELECT salary FROM employees WHERE employee_id = 89898. all employees in department 10 have the same salary value. Which statement would you use? Mark for Review (1) Points . Correct 93. (*) An error message would be returned. You need to remove a row from the EMPLOYEES table. Only one row would be deleted. 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. No rows would be deleted.UPDATE employees SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id = 10). CREATE MERGE. MERGE (*) INSERT. CREATE INSERT.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. UPDATE . (*) UPDATE employees SET salary = salary * 1.15 WHERE department_id = 10. Which statement should you use? Mark for Review (1) Points UPDATE employees SET salary = salary * 1.15 WHERE department_id = 10. .10.2) BONUS NUMBER(9.Correct 95.2) You need to increase the salary for all employees in department 10 by 10 percent.10 AND bonus = bonus * 1. You also need to increase the bonus for all employees in department 10 by 15 percent. 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. bonus = bonus * 1. 15) WHERE department_id = 10.10. Correct 96. bonus = bonus * . What keyword in an UPDATE statement specifies the columns you want to change? Mark for Review (1) Points SELECT WHERE SET (*) .15 WHERE department_id = 10. UPDATE employees SET salary = salary * .UPDATE employees SET (salary = salary * 1.10) SET (bonus = bonus * 1. 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.HAVING Incorrect. In which clause of the UPDATE statement will you specify this condition? Mark for Review (1) Points the ON clause . The statement removes the structure of the CUSTOMER table from the database. Refer to Section 7 97. (*) The statement deletes the CUSTOMER column. You need to update the expiration date of products manufactured before June 30th. The statement deletes the first row in the CUSTOMERS table. Correct 98. (*) INSERT customers VALUES 3178. '123 Main Street'.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777'.. J. 37777. TN. 'Nashville'. 'Smith'. 'TN'. 'J. Nashville. '37777'). INSERT INTO customers VALUES '3178' 'J.the WHERE clause (*) the SET clause the USING clause Correct 99. 123 Main Street. Smith. Which of the following represents the correct syntax for an INSERT statement? Mark for Review (1) Points INSERT VALUES INTO customers (3178 J. Correct . INSERT INTO customers VALUES (3178.'. Smith 123 Main Street Nashville TN 37777. 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'.100. has informed you that she was recently married. Her new last name is Cooper. and she has requested that you update her name in the employee database. One of the sales representatives. (*) UPDATE employees last_name = 'cooper' WHERE last_name = 'roper'. Janet is the only person with the last name of Roper that is employed by the company. Janet Roper. UPDATE employees . SET last_name = 'roper' WHERE last_name = 'cooper'. Correct Page 10 of 10 Section 1 Lesson 1 (Answer all questions in this section) . UPDATE employees SET cooper = 'last_name' WHERE last_name = 'roper'. LOWER (*) Correct 2. SUBSTR. SUBSTR SUBSTR. CONCAT. SUBSTR. 1. first_name)). CONCAT. 5) "ID" FROM employee. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. In which order are the functions evaluated? Mark for Review (1) Points LOWER. 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 .1. LOWER CONCAT. CONCAT LOWER. CONCAT INSTR (*) LENGTH SUBSTR Correct 3. TRUNC. and TRIM (*) UPPER. and ADD_MONTHS . number. Which functions can be used to manipulate character. TRUNC. and MOD ROUND. RPAD. and date column values? Mark for Review (1) Points CONCAT. LOWER. and INITCAP ROUND. You query the database with this SQL statement: SELECT CONCAT(last_name.Correct 4. Which function will be evaluated first? Mark for Review (1) Points CONCAT SUBSTR LOWER (*) All three will be evaluated simultaneously. 4))) "Default Password" FROM employees. (SUBSTR(LOWER(first_name). Correct . You need to display the number of characters in each customer's last name.5. (*) The CONCAT function can only be used on character strings.) Mark for Review (1) Points (Choose all correct answers) The SYSDATE function returns the Oracle Server date and time. not on numbers. The SUBSTR character function returns a portion of a string beginning at a defined character position to a specified length. Which function should you use? Mark for Review (1) Points LENGTH (*) LPAD . (*) Correct 6. (*) The ROUND number function rounds a value to a specified decimal place or the nearest whole number. Which three statements about functions are true? (Choose three. 2) FROM price WHERE manufacturer_id = 59604. The PRICE table contains this data: PRODUCT_ID MANUFACTURER_ID 86950 59604 You query the database and return the value 95. (*) SELECT LENGTH(product_id. 2) . 3. Which script did you use? Mark for Review (1) Points SELECT SUBSTR(product_id. 3.COUNT SUBSTR Correct 7. 3) FROM price WHERE manufacturer_id = 59604. 2) FROM price WHERE manufacturer_id = 59604. SELECT TRIM(product_id.FROM price WHERE manufacturer_id = 59604. -3. Refer to Section 1 Section 1 Lesson 2 (Answer all questions in this section) 8.) Mark for Review (1) Points . Incorrect. but NOT character column values? (Choose two. -1. Which two functions can be used to manipulate number or date column values. SELECT SUBSTR(product_id. (Choose all correct answers) RPAD TRUNC (*) ROUND (*) INSTR CONCAT Correct 9.367. You issue this SQL statement: SELECT TRUNC(751. Which value does this statement display? Mark for Review (1) Points .-1) FROM dual. 'MONTH') FROM employees.700 750 (*) 751 751. (*) SELECT ROUND(hire_date. . Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review (1) Points SELECT TRUNC(hire_date.3 Correct 10. 'MONTH') FROM employees. TO_DATE('25-JUN-02') + hire_date FROM employees. Section 1 Lesson 3 (Answer all questions in this section) 11. SELECT TRUNC(hire_date. 'MI') FROM employees. SELECT (SYSDATE .SELECT ROUND(hire_date. Which SELECT statement will NOT return a date value? Mark for Review (1) Points SELECT (30 + hire_date) + 1440/24 FROM employees.hire_date) + 10*8 FROM employees. (*) SELECT SYSDATE . 'MON') FROM employees. . Incorrect. Refer to Section 1 12.SYSDATE) + TO_DATE('25-JUN-02') FROM employees. Which function would you use to return the current database server date and time? Mark for Review (1) Points DATE SYSDATE (*) DATETIME CURRENTDATE Correct .SELECT (hire_date . hire_date) / 7 FROM employee. (*) SELECT SYSDATE . SELECT (SYSDATE . SELECT ROUND(hire_date. DAY) FROM employee.13.7 FROM employee. Which SELECT statement will return a numeric value? Mark for Review (1) Points SELECT SYSDATE + 600 / 24 FROM employee. Correct 14. Which of the following Date Functions will add calendar months to a date? Mark for Review . You need to subtract three months from the current date.(1) Points Months + Calendar (Month) ADD_MONTHS (*) MONTHS + Date NEXT_MONTH Correct 15. Which function should you use? Mark for Review (1) Points ROUND TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN . TO_CHAR (sysdate. dd month. SELECT companyname. You have been asked to create a report that lists all customers who have placed orders of at least $2. 'fmdd. total FROM customers NATURAL JOIN orders WHERE total >= 2500. SELECT companyname. total FROM customers NATURAL JOIN orders . dy month. Year format (For example. 'day. 'dd. Tuesday. total FROM customers NATURAL JOIN orders WHERE total >= 2500.500. yyyy'). The report's date should be displayed in the Day. dy month. Date Month. TO_DATE (date. 2004 ). Which statement should you issue? Mark for Review (1) Points SELECT companyname. yyyy'). TO_DATE (sysdate. 13 April. yyyy').Correct Section 2 Lesson 1 (Answer all questions in this section) 16. (*) Correct 17. TO_CHAR (sysdate. 'fmDay. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001.WHERE total >= 2500. yyyy'). total FROM customers NATURAL JOIN orders WHERE total >= 2500. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 . SELECT companyname. dd Month. 00. Each employee's salary must be displayed in the following format: $000.000. Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . 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. You have been asked to create a report that displays each employee's name and salary.Correct 18. All Human Resources data is stored in a table named EMPLOYEES.TO_DATE('01-OCT-2004') (*) NEXT_DAY(hire_date) + 5 . (*) Use the TO_NUMBER function to convert a character string of digits to a number.SYSDATE . Use the TO_DATE function to convert a character string to a date value. Use the TO_CHAR function to convert a number or date value to character string. Which three statements concerning explicit data type conversions are true? (Choose three. (*) Use the TO_DATE function to convert a date value to character string or number.6 SYSDATE + 30 / 24 Correct 20.) Mark for Review (1) Points (Choose all correct answers) Use the TO_NUMBER function to convert a number to a character string. (*) Section 2 Lesson 1 . The PRODUCT table contains this column: PRICE NUMBER(7.(Answer all questions in this section) 21. Single row functions cannot modify a data type. Correct Section 2 Lesson 2 (Answer all questions in this section) 22. Single row functions can be nested. (*) Single row functions return one or more results per row. but can return multiple values. Which statement concerning single row functions is true? Mark for Review (1) Points Single row functions can accept only one argument.2) Evaluate this statement: . (*) A value of 10 would be displayed. '0') FROM PRODUCT. The statement would fail because values cannot be divided by null.SELECT NVL(10 / price. Correct 23. A value of 0 would be displayed. Which of the following General Functions will return the first non-null expression in the expression list? Mark for Review (1) Points NVL NVL2 . 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. and COALESCE can be used with group functions to replace null values. NVL.NULLIF COALESCE (*) Correct 24. but not COALESCE. can be used with group functions to replace null values. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. can be used with group functions to replace null values. (*) COALESCE. but not NVL and NVL2. but not NVL2. NVL and COALESCE. can be used with group functions to replace null values. NVL2. Correct . department_id AND employees. e. Evaluate this SQL statement: SELECT e.last_name.department_id = d.department_id = d. e.department_id > 5000 ORDER BY 4.Section 3 Lesson 2 (Answer all questions in this section) 25.department_name FROM employees e.employee_id. departments d WHERE e.employee_id.department_name FROM employees e. Which clause contains a syntax error? Mark for Review (1) Points SELECT e.last_name. . departments d WHERE e.first_name. d.first_name.department_id AND employees.department_id > 5000 (*) ORDER BY 4. d. e. e. first_name.employee_id = s. (*) SELECT e.employee_id AND revenue >= 100000. or more.employee_id = s. SELECT e. You want to identify the sales representatives who have generated $100. e.employee_id AND revenue >= 100000. Which query should you issue? Mark for Review (1) Points SELECT e.sales FROM employees e.Correct 26. sales .first_name. s.last_name.000. last_name.sales FROM employees e.employee_id AND revenue > 100000.employee_id = s. sales s WHERE e.sales FROM employees. s.last_name. sales s WHERE e. e. s.first_name. sales WHERE e.last_name. Your have two tables named EMPLOYEES and SALES. in revenue. SELECT first_name. e. sales s WHERE e. 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.employee_id AND revenue > 100000. 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 . one column to the next column. 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.Q FROM employees e. Correct 27.employee_id = s. the company and the total sales? .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. company.cust_id.cust_id. (*) SELECT cust_id. sales s WHERE c.cust_id (+). . company. SELECT c.cust_id = s. sales WHERE cust_id = cust_id.Mark for Review (1) Points SELECT c.cust_id. total_sales FROM customers. s.cust_id = s.total_sales FROM customers c.cust_id. c. c.cust_id = s. total_sales FROM customers c.total_sales FROM customers c. sales s WHERE c. company. s. sales s WHERE c. SELECT cust_id.company. 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. Which of the following queries should you issue? Mark for Review (1) Points . as a calculation of salary times bonus. employee_id = b.last_name.first_name.employee_id = b. bonus_pct FROM employees e.SELECT e. b. Evaluate this SELECT statement: . e.first_name. SELECT first_name. b. e. bonus b WHERE e.employee_id. b.annual_salary. bonus WHERE e. bonus NATURAL JOIN.employee_id. last_name. bonus b WHERE e.first_name. bonus_pct FROM employees e. annual_salary * bonus_pct FROM employees. (*) SELECT e. SELECT e. b.annual_salary.last_name.employee_id = b.last_name.employee_id. bonus_pct FROM employees. Section 3 Lesson 4 (Answer all questions in this section) 31. b.annual_salary * b. e. 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.manager_id = m. t.last_name. 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.player_id) LEFT OUTER JOIN team t ON (p.team_id).first_name.player_id.SELECT p. m.team_name FROM player p LEFT OUTER JOIN player m ON (p. . m.team_id = t. AND. 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. Using Oracle Proprietary join syntax.... and IN IN and = Correct . 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..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. (*) Correct 33. Section 4 Lesson 2 (Answer all questions in this section) 34. Columns with the same names cannot be included in the SELECT list of the query. (*) Columns with the same names must have compatible data types. Correct 35. Columns with the same names must have the same precision and datatype. Which of the following conditions will cause an error on a NATURAL JOIN? Mark for Review (1) Points . Which statement about a natural join is true? Mark for Review (1) Points Columns with the same names must have identical data types. (*) Correct 36. then an error is returned. If the columns having the same names have different data types. When the NATURAL JOIN clause is based on all columns in the two tables that have the same name. 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 .When you attempt to write it as an equijoin. If it selects rows from the two tables that have equal values in all matched columns. You need to join all the rows in the EMPLOYEES table to all the rows in the EMP_REFERENCES table. The CUSTOMER and ORDER tables have a corresponding column. CUST_ID. Correct 38. 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 CUSTOMER and ORDER tables have no columns with identical names. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE statements in sequence: .Section 4 Lesson 3 (Answer all questions in this section) 37. (*) The ORDER table contains a column that has a referential constraint to a column in the PRODUCT table. The CUST_ID column in the ORDER table contains null values that need to be displayed. CREATE TABLE orders (orderid varchar2(5) constraint pk_orders_01 primary key. companyname varchar2(30). contactname varchar2(30). You have been instructed to compile a report to present the information about orders placed by customers who reside in Nashville . phone varchar2(20). custid varchar2(5) references customers (custid)). state varchar2(30). orderdate date. address varchar2(30). companyname FROM customers WHERE city = 'Nashville'. Which query should you issue to achieve the desired results? Mark for Review (1) Points SELECT custid. .CREATE TABLE customers (custid varchar2(5). city varchar2(20). total number(15). constraint pk_customers_01 primary key (custid)). SELECT orderid.custid WHERE city = 'Nashville'. (*) SELECT orderid. SELECT orderid. orderdate.custid = c. total FROM orders o NATURAL JOIN customers c ON o. total FROM orders o JOIN customers c ON o. Below find the structures of the PRODUCTS and VENDORS tables: PRODUCTS .custid WHERE city = 'Nashville'. total FROM orders WHERE city = 'Nashville'. orderdate. orderdate. Correct 39.custid = c. vendor_name FROM products p LEFT OUTER JOIN vendors v ON p. for all products that have a vendor assigned.vendor_id = v.vendor_id .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. v. including the product name and associated vendor name. Which two queries could you use? Mark for Review (1) Points (Choose all correct answers) SELECT p.product_name. product_name.vendor_name FROM products p NATURAL JOIN vendors v ORDER BY p. SELECT p. v.vendor_name FROM products p JOIN vendors v USING (vendor_id) ORDER BY p.product_name. (*) SELECT p.vendor_id) ORDER BY p.product_name.product_name. v. v. v.product_name.product_name.vendor_name FROM products p JOIN vendors v ON (vendor_id) ORDER BY p.product_name.product_name. SELECT p.ORDER BY p. SELECT p.vendor_name FROM products p JOIN vendors v USING (p.product_name. . (*) Incorrect. Which query represents the correct syntax for a left outer join? Mark for Review (1) Points SELECT companyname. 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. orderdate. total . Refer to Section 4 40. orderdate. SELECT companyname. orderdate.cust_id.cust_id.cust_id = o.cust_id = o. total FROM customers c OUTER JOIN orders o ON c. SELECT companyname.cust_id. orderdate.cust_id = o. total FROM customers c LEFT OUTER orders o ON c. (*) SELECT companyname. total FROM customers c LEFT OUTER JOIN orders o ON c. .cust_id.cust_id = o.FROM customers c LEFT JOIN orders o ON c. last_name. e.department_id.department_id).department_name FROM employees e RIGHT OUTER JOIN departments d ON (e.last_name.department_id. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e.department_id = d.department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_id.last_name. (*) SELECT e. e. e.department_id = d. d.department_name FROM employees e NATURAL JOIN departments d. e.department_id). d.Correct 42.department_id = d. . d. d.department_name FROM employees e JOIN departments d USING (e. Which query will retrieve all the rows in the EMPLOYEES table.department_id.department_id). SELECT e. SELECT e.last_name. 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) . Refer to Section 4 43.Incorrect. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Which values are displayed? Mark for Review (1) Points .44. Evaluate this SELECT statement: SELECT MIN(hire_date). 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. department_id FROM employees GROUP BY department_id. A GROUP BY clause cannot be used without an ORDER BY clause. The latest hire date in the EMPLOYEES table. Correct 46. (*) The last column listed in the GROUP BY clause is the most major grouping. The hire dates in the EMPLOYEES table that contain NULL values. . (*) The the earliest hire date in the EMPLOYEES table. 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 GROUP BY clause can contain an aggregate function.The earliest hire date in each department. Correct Section 5 Lesson 2 .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. You cannot use a column alias in the GROUP BY clause. Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. The department id is not listed in the departments table. (*) The GROUP BY clause must have something to GROUP. (Answer all questions in this section) 48. SUM. VARIANCE. and STDDEV functions can be used with which of the following? Mark for Review (1) Points Only numeric data types (*) Integers only . The AVG. 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. number and date data types? (Choose three) Mark for Review (1) Points . 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.Any data type All except numeric Correct 50. Mark for Review (1) Points a row set.(Choose all correct answers) SUM MAX (*) MIN (*) AVG COUNT (*) Correct 52. ignore a row set. Group functions return a value for ________________ and ________________ null values in their computations. ignore (*) each row. include . include Correct 53.each row. 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 . 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. 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'. February and March of 2003.89453485 8549038 15-FEB-03 INTEREST 596. (*) SELECT AVG(payment_amount) FROM payment.00 You need to determine the average payment amount made by each customer in January. SELECT AVG(payment_amount) FROM payment . SELECT SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'.00 85490345 5489304 20-MAR-03 BASIC 568. Which group function should you use to calculate this value? Mark for Review (1) Points AVG (*) SUM COUNT . FEB. MAR). Correct 55.WHERE TO_CHAR(payment_date) IN (JAN.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. The CUSTOMERS table contains these columns: CUSTOMER_ID NUMBER(9) FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7. 00 968950 SANDAL 85909 10.00 869506 SANDAL 89690 15.00 809090 LOAFER 89098 10.00 857689 HEEL 85940 11.00 890890 LOAFER 89789 14.STDDEV Correct Section 5 Lesson 3 (Answer all questions in this section) 56.00 758960 SANDAL 86979 You issue this SELECT statement: SELECT COUNT(category) . The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. FROM styles. (*) . Correct 57. Which statement about the COUNT function is true? Mark for Review (1) Points The COUNT function ignores duplicates by default. Which value is displayed? Mark for Review (1) Points 0 6 7 (*) The statement will NOT execute successfully. The COUNT function always ignores null values by default. 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 . non-null values in a column. Correct 58. The COUNT function can be used to determine the number of unique.The COUNT function can be used to find the maximum value in each column. (*) SELECT ROWCOUNT FROM products. SELECT COUNT (*) FROM products. SELECT COUNT FROM products.(1) Points SELECT COUNT(products). Evaluate this SELECT statement: SELECT SUM(salary). department_id FROM employees GROUP BY department_id. How are the results of this statement sorted? . Correct Section 6 Lesson 1 (Answer all questions in this section) 60. Which statement could you use to accomplish this task? Mark for Review (1) Points .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. SELECT prod_cat. prod_cat. MIN (prod_price) FROM products GROUP BY prod_cat. MIN (prod_cat) FROM products GROUP BY prod_cat. SELECT prod_price. MIN (prod_price) FROM products GROUP BY prod_price. (*) SELECT MIN (prod_price). SELECT prod_cat. Correct . prod_cat FROM products GROUP BY MIN (prod_price). sorted by departments. (*) .62. You want to write a report that returns the average salary of all employees in the company. SELECT AVG (salary) FROM employees GROUP BY department. 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 BY department.SELECT AVG (salary) FROM employees BY department. Refer to Section 6 63.2) Which two clauses represent valid uses of aggregate functions? (Choose three. The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8. Incorrect.) Mark for Review (1) Points . (Choose all correct answers) ORDER BY AVG(salary) (*) GROUP BY MAX(salary) SELECT AVG(NVL(salary. Evaluate this SELECT statement: SELECT SUM(salary). based on a group function? Mark for Review (1) Points . Which SELECT statement clause allows you to restrict the rows returned. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Incorrect. department_id. Refer to Section 6 64. manager_id FROM employees GROUP BY department_id. manager_id. You only want to include employees who earn more than 15000. Evaluate this SELECT statement: SELECT COUNT(employee_id). department_id FROM employees GROUP BY department_id.HAVING SUM(salary) > 100000 (*) WHERE SUM(salary) > 100000 WHERE salary > 100000 HAVING salary > 100000 Correct 65. 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 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. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. 2003 ? Mark for Review (1) Points SELECT customer_id. SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. Correct 67. SELECT customer_id. department_id . Evaluate this statement: SELECT department_id.SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. Which clauses restricts the result? Choose two. 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) . Mark for Review (1) Points (Choose all correct answers) SELECT department_id.HAVING AVG(salary) > 35000 ORDER BY department_id. product_name FROM products WHERE cost > AVG(cost) GROUP by product_name. 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 (SELECT AVG(cost) FROM product) WHERE cost > AVG(cost). .68. (*) SELECT product_name FROM products WHERE cost > AVG(cost). You need to create a report to display the names of products with a cost value greater than the average cost of all products. SELECT AVG(cost). Examine the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8. Which operator can be used with subqueries that return only one row? Mark for Review (1) Points LIKE (*) ANY ALL IN Correct 70.2) .Correct 69. 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.OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. You need to display all the orders that were placed on the same day as order number 25950. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns: . You need to display all the orders that were placed on a certain date. (*) Section 6 Lesson 2 (Answer all questions in this section) 71. (*) SELECT * .) Mark for Review (1) Points (Choose all correct answers) SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments).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. SELECT * FROM teachers WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0). Which operator can be used with a multiple-row subquery? Mark for Review . Correct 72. (*) SELECT * FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0).FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963). SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id). 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 .(1) Points IN (*) <> = LIKE Correct 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 .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. 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. If a single-row subquery returns a null value and uses the equality comparison operator. (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 (*) . (*) No rows will be selected.Compare value to every value returned by the subquery Equal to each value in the list Correct 77. Correct . The data returned may or may not be correct. 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. All the rows will be selected. 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. You need to display all the products that cost more than the maximum cost of every product produced in Japan.2) DEPART_HIST: . Which multiple-row comparison operator could you use? Mark for Review (1) Points >ANY (*) NOT=ALL IN >IN Correct 79. 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. last_name. first_name. department_id) IN (SELECT employee_id. department_id FROM employee WHERE (employee_id) IN (SELECT employee_id FROM employee_hist WHERE old_dept_id = 15). (*) SELECT employee_id. first_name. Which query should you use? Mark for Review (1) Points SELECT employee_id. new_dept_id FROM depart_hist WHERE old_dept_id = 15) AND new_dept_id = 10. but used to be in department 15. . last_name. department_id FROM employee WHERE (employee_id. last_name. first_name. dept_id FROM employee WHERE old_dept_id = 15). department_id FROM employee WHERE (employee_id. department_id) IN (SELECT employee_id. Correct 80. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT . department_id) = (SELECT employee_id. first_name. department_id FROM employee WHERE (employee_id. last_name. SELECT employee_id.SELECT employee_id. new_dept_id FROM depart_hist WHERE new_dept_id = 15). Which change could correct the problem? Mark for Review (1) Points Remove the subquery WHERE clause. Remove the single quotes around the date value in the inner query WHERE clause. payment_amount FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500. Change the outer query WHERE clause to 'WHERE payment_id IN'. customer_id. .00 89453485 8549038 15-FEB-03 INTEREST 596.00 This statement fails when executed: SELECT payment_date.00).00 85490345 5489304 20-MAR-03 BASIC 568.86590586 8908090 10-JUN-03 BASIC 859. (*) Include the PAYMENT_ID column in the select list of the outer query. . 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). A multiple-row operator expects how many values? Mark for Review (1) Points One or more (*) Only one Two or more None Correct 82.Section 7 Lesson 2 (Answer all questions in this section) 81. Evaluate this SELECT statement: SELECT student_id. last_name. (*) Correct 83. SELECT description FROM d_types WHERE code <> ALL (SELECT type_code FROM d_songs). .SELECT description FROM d_types WHERE code = ANY (SELECT type_code FROM d_songs). first_name FROM student WHERE major_id NOT IN (SELECT major_id FROM majors WHERE department_head_id = 30 AND title = 'ADJUNCT'). All of the above. Correct 84. Only the rows with STUDENT_ID values equal to NULL would be displayed. (*) All the rows in the STUDENT table would be displayed.2) PRICE NUMBER(5.2) . 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.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. 'DALLAS ')). price.15 WHERE manufacturers_id = (SELECT id FROM manufacturers WHERE UPPER(location) IN('ATLANTA '. cost FROM parts WHERE manufacturers_id != (SELECT id FROM manufacturers WHERE LOWER(name) = 'cost plus'). cost .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. SELECT parts_name. price. SELECT parts_name. 'BOSTON '. Refer to Section 6 85. last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). What is wrong with the following query? SELECT employee_id. .id = p.manufacturers_id)). (*) SELECT parts_name FROM (SELECT AVG(cost) FROM manufacturers) WHERE cost > AVG(cost).FROM parts WHERE manufacturers_id IN (SELECT id FROM manufacturers m JOIN part p ON (m. Incorrect. . Correct 86. You need to create a SELECT statement that contains a multiple-row subquery. <. and > .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. ANY. which comparison operator(s) can you use? Mark for Review (1) Points IN..AND. Nothing.. and ALL (*) LIKE BETWEEN. it will run without problems. you should not add an amount to the CREDIT column. poc. You have been instructed to add a new customer to the CUSTOMERS table. company. Because the new customer has not had a credit check. location) . 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.Correct Section 7 Lesson 1 (Answer all questions in this section) 87. 0. Which DML statement should you use? Mark for Review (1) Points UPDATE . Correct 88. location) (200. 'tflanders'. 'samerica'). 'samerica'). 'InterCargo'. company. 'tflanders'. (*) INSERT INTO customers VALUES (cust_id. poc. INSERT INTO customers VALUES (200. 'InterCargo'. 'InterCargo'.VALUES (200. (*) INSERT INTO customers VALUES (200. You need to add a row to an existing table. samerica). null. tflanders. 'samerica'). InterCargo. 0. credit. 'tflanders'. Which statement about the VALUES clause of an INSERT statement is true? Mark for Review (1) Points If no column list is specified. and numeric data must be enclosed within single quotes in the VALUES clause. (*) The VALUES clause in an INSERT statement is optional. Character. Correct . then the values must be in the order the columns are specified in the table. use an empty string (' '). To specify a null value in the VALUES clause. date.INSERT (*) DELETE CREATE Correct 89. supplier_id VALUES (2958.90.04. SYSDATE). 7. 8690. 4. INSERT INTO products(product_id.2) COST NUMBER (5. (*) INSERT INTO products VALUES (2958.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. 8690. product_name. 'Cable'. 91. 'Cable'. 8690. 'Cable'. 7. 4. Which statement would you use? Mark for Review (1) Points .09.04. You need to remove a row from the EMPLOYEES table. INSERT INTO products(product_id.09. 700). 'Cable'). The PRODUCTS table contains these columns: PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. SYSDATE). product_name) VALUES (2958. Primary Key PRODUCT_NAME VARCHAR2 (25) . 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.UPDATE with a WHERE clause INSERT with a WHERE clause DELETE with a WHERE clause (*) MERGE with a WHERE clause Correct 92. 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.SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table CATEGORY_ID NUMBER QTY_PER_UNIT NUMBER UNIT_PRICE NUMBER (7. (*) DELETE FROM products WHERE UPPER(city) = 'ATLANTA'. DELETE FROM products . 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 supplier_id < (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA'). Her new last name is Cooper. 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) . and she has requested that you update her name in the employee database. Janet Roper. Correct 93.WHERE supplier_id = (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA'). Janet is the only person with the last name of Roper that is employed by the company. has informed you that she was recently married. One of the sales representatives. UPDATE employees SET last_name = 'roper' WHERE last_name = 'cooper'. (*) UPDATE employees last_name = 'cooper' WHERE last_name = 'roper'. .Which UPDATE statement will accomplish your objective? Mark for Review (1) Points UPDATE employees SET last_name = 'cooper' WHERE last_name = 'roper'. UPDATE employees SET cooper = 'last_name' WHERE last_name = 'roper'. 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. You need to update the expiration date of products manufactured before June 30th.Correct 94. 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. (*) An error message would be returned. . however. Correct 96.No rows would be deleted. One of your employees was recently married. her last name is now Rockefeller. (*) Correct 97. INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. Which two commands can be used to modify existing data in a database row? Mark for Review . Her employee ID is still 189. UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. 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. Only one row would be deleted. What keyword in an UPDATE statement specifies the columns you want to change? Mark for Review (1) Points SELECT WHERE SET (*) .(1) Points (Choose all correct answers) DELETE MERGE (*) SELECT UPDATE (*) Correct 98. WHERE city = 'Atlanta'. You need to update the area code of employees that live in Atlanta . Correct .HAVING Incorrect. 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'. Refer to Section 7 99. (*) LIKE 'At%'. feedback.100. Section 1 Lesson 1 (Answer all questions in this section) 1. 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 . and question scores below. number. An asterisk (*) indicates a correct answer.Database Programming with SQL Review your answers. Which functions can be used to manipulate character. and date column values? Mark for Review . You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES table using one UPDATE statement. and TRIM (*) UPPER. You need to display each employee's name in all uppercase letters. TRUNC. and MOD ROUND. TRUNC.(1) Points CONCAT. RPAD. and INITCAP ROUND. LOWER. Which function should you use? Mark for Review (1) Points CASE UCASE UPPER (*) TOUPPER . and ADD_MONTHS Correct 2. Which three statements about functions are true? (Choose three. (*) The CONCAT function can only be used on character strings. 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 .Correct 3. not on numbers.) 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 last name and the format of the salary limited to 15 digits to the left of the decimal and the column labeled SALARY. '$')SALARY FROM employees. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value.LPAD CUT NVL2 TRIM (*) Correct 5. LPAD(salary. size of 15 and the column labeled SALARY. What will the following SQL statement display? SELECT last_name. 15. (SUBSTR(LOWER(first_name). (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. leftpadded with the $ and the column labeled SALARY.The last name and salary for all employees with the format of the salary 15 characters long. Refer to Section 1 6." Incorrect. 4))) "Default Password" FROM employees. Which function will be evaluated first? Mark for Review (1) Points CONCAT SUBSTR LOWER (*) . You query the database with this SQL statement: SELECT CONCAT(last_name. 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. Evaluate this SELECT statement: SELECT LENGTH(email) FROM employees.All three will be evaluated simultaneously. . Correct 7. 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 value does this statement display? Mark for Review (1) Points 700 750 (*) 751 751.367.Correct Section 1 Lesson 2 (Answer all questions in this section) 8.-1) FROM dual. You issue this SQL statement: SELECT TRUNC(751. ) Mark for Review (1) Points (Choose all correct answers) RPAD TRUNC (*) ROUND (*) INSTR CONCAT Correct 10. Which two functions can be used to manipulate number or date column values. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review . but NOT character column values? (Choose two.Correct 9. SELECT ROUND(hire_date. 'MI') FROM employees. 'MONTH') FROM employees. 'MONTH') FROM employees. SELECT TRUNC(hire_date.(1) Points SELECT TRUNC(hire_date. (*) SELECT ROUND(hire_date. Correct Page 1 of 10 . 'MON') FROM employees. Database Programming with SQL Review your answers.Test: Mid Term Exam . and question scores below. Which function should you use? Mark for Review (1) Points ROUND BETWEEN ADD_MONTHS MONTHS_BETWEEN (*) . An asterisk (*) indicates a correct answer. Section 1 Lesson 3 (Answer all questions in this section) 11. feedback. You need to display the number of months between today's date and each employee's hiredate. SELECT last_name. 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)AS WEEK . SELECT last_name.Correct 12. (SYSDATE-hire_date)/7 AS WEEKS FROM employees WHERE department_id = 90. (SYSDATE-hire_date)/7 DISPLAY WEEKS FROM employees WHERE department id = 90. # of WEEKS FROM employees WHERE department_id = 90. (*) SELECT last name. Which query should you issue? Mark for Review (1) Points SELECT orderid. total FROM orders WHERE order_date IN ( 01-jan-02 . 31-jan-02 ) ORDER BY total.FROM employees WHERE department_id = 90. SELECT orderid. You want to create a report that displays all orders and their amounts that were placed during the month of January. Correct 13. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC. You want the orders with the highest amounts to appear first. total . SELECT orderid. 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: . total FROM orders WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02' ORDER BY total DESC. (*) SELECT orderid.FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' ORDER BY total DESC. Correct 14. The values returned by this SELECT statement will be of which data type? Mark for Review (1) Points DATE (*) NUMBER DATETIME INTEGER Correct 15. Which function should you use? Mark for Review (1) Points ROUND .SELECT hire_date + eval_months FROM employees. You need to subtract three months from the current date. 6 .TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN Correct Section 2 Lesson 1 (Answer all questions in this section) 16.TO_DATE('01-OCT-2004') (*) NEXT_DAY(hire_date) + 5 SYSDATE . Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . The TO_CHAR function can be used to display dates and numbers according to formatting conventions that are supported by Oracle.SYSDATE + 30 / 24 Correct 17. The TO_CHAR function can be used to remove text from column data that will be returned by the database. 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. Correct 18. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) . (*) The TO_CHAR function can only be used on DATE columns. 00"? Mark for Review (1) Points SELECT TO_CHAR(salary.999') FROM employees. (*) . '$999. SELECT TO_CHAR(salary. SELECT TO_NUM(salary.999.LAST_NAME VARCHAR2 (25) FIRST_NAME VARCHAR2 (25) SALARY NUMBER(6) You need to create a report to display the salaries of all employees. '$999.999.990.000.00') FROM employees. SELECT TO_NUM(salary. '$999. '$999.00') FROM employees.99') FROM employees. Which script should you use to display the salaries in format: "$45. All Human Resources data is stored in a table named EMPLOYEES.00. 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.) Mark for Review (1) Points (Choose all correct answers) . 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.000.Correct 19. Which two statements concerning SQL functions are true? (Choose two. Refer to Section 2 Page 2 of 10 Test: Mid Term Exam . (*) Number functions can return number or character values.Database Programming with SQL . (*) Single-row functions manipulate groups of rows to return one result per group of rows. Incorrect. Conversion functions convert a value from one data type to another data type. Not all date functions return date values.Character functions can accept numeric input. Correct Section 2 Lesson 2 . "$99.99") FROM product.900.99') FROM product.99) FROM product.99') FROM product. An asterisk (*) indicates a correct answer. Section 2 Lesson 1 (Answer all questions in this section) 21.900. (*) SELECT TO_CHAR(price. $99.900. and question scores below.Review your answers.30"? Mark for Review (1) Points SELECT TO_CHAR(price.990. SELECT TO_CHAR(price. Which SQL Statement should you use to display the prices in this format: "$00. '$99. '$99. SELECT TO_CHAR(price. feedback. can be used with group functions to replace null values. 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 . Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. and COALESCE can be used with group functions to replace null values. Refer to Section 2 23. can be used with group functions to replace null values. NVL. NVL and COALESCE.(Answer all questions in this section) 22. can be used with group functions to replace null values. (*) COALESCE. NVL2. but not NVL and NVL2. Incorrect. but not NVL2. but not COALESCE. 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 ORDER BY category. category. cost.00 857689 HEEL 85940 11. 0) < 15. style_name.COALESCE (*) Incorrect.00 758960 SANDAL 86979 Evaluate this SELECT statement: SELECT style_id. Refer to Section 2 24.00 809090 LOAFER 89098 10. cost FROM styles WHERE style_name = 'SANDAL' AND NVL(cost.00 890890 LOAFER 89789 14. 00 869506 SANDAL 89690 15.00 758960 SANDAL 86979 STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85909 12.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 .00 968950 SANDAL 85909 10.00 758960 SANDAL 86979 869506 SANDAL 89690 15. 00 895840 SANDAL 85940 12. When joining 3 tables in a SELECT statement. how many join conditions are needed in the WHERE clause? Mark for Review (1) Points 0 .STYLE_ID STYLE_NAME CATEGORY COST 968950 SANDAL 85909 10.00 758960 SANDAL 86979 (*) Incorrect. Refer to Section 2 Section 3 Lesson 2 (Answer all questions in this section) 25. 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 26. Refer to Section 3 .1 2 (*) 3 Incorrect. first_name. first_name. first_name. SELECT last_name. salary FROM employees WHERE salary = 25000 AND department_id = 10. SELECT last_name. SELECT last_name. (*) . 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. salary FROM employees WHERE salary != 25000 AND department_id = 10.27. salary FROM employees WHERE salary <= 25000 AND department_id = 10.000 per year. You need to create a report that lists all employees in department 10 (Sales) whose salary is not equal to $25. doctors.Correct 28. doctor_id FROM patients. 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. 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 . The FROM clause represents the join criteria. The JOIN keyword must be included. 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.A report with NO duplicate PATIENT_ID or DOCTOR_ID values A syntax error Correct 29. Refer to Section 3 30. (*) Incorrect. What happens when you create a Cartesian product? Mark for Review . The WHERE clause represents the join criteria. (1) Points All rows from one table are joined to all rows of another table (*) The table is joined to itself.Database Programming with SQL . 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 . one column to the next column. feedback.Review your answers. . 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. Using Oracle Proprietary join syntax. and question scores below. 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. Section 3 Lesson 4 (Answer all questions in this section) 31. An asterisk (*) indicates a correct answer. m. (*) Correct 33.player_id) LEFT OUTER JOIN team t ON (p. 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 .manager_id = m. Evaluate this SELECT statement: SELECT p. m.first_name.team_id = t.team_id).An outer join will return only data from the far left column in one table and the far right column in the other table.team_name FROM player p LEFT OUTER JOIN player m ON (p.last_name. 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.player_id. t. An outer join will return data only if both tables contain an identical pair of columns. 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 .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. The last_name and department name from the employee table.Simple join (*) Full outer join Correct 35. (*) A cross referenced result omitting similar fields from the two tables. A Cartesian product between the two tables. Mark for Review (1) Points The missing rows from the join condition. The following SQL statement will produce what output? SELECT last_name. department_name FROM employees CROSS JOIN departments. . (*) 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. Columns with the same names must have the same precision and datatype.Correct 36. Which keyword in a SELECT statement creates an equijoin by specifying a column name common to both tables? Mark for Review . Which statement about a natural join is true? Mark for Review (1) Points Columns with the same names must have identical data types. (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 . physician_id) .last_name || '. c. 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.physician_id = c. Evaluate this SELECT statement: SELECT a.Correct 39. b. ' || a. ' || b. A join that joins a table to itself Correct 40.admission FROM patient a JOIN physician b ON (b. A join condition that includes the (+) on the left hand side.first_name as "Patient".last_name || '.first_name as "Physician". patient_id = c. Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b.patient_id = c.physician_id = c.patient_id) Correct Page 4 of 10 .physician_id) (*) JOIN admission c ON (a.JOIN admission c ON (a.patient_id). 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 . and question scores below. Section 4 Lesson 4 (Answer all questions in this section) 41.Test: Mid Term Exam .Database Programming with SQL Review your answers. An asterisk (*) indicates a correct answer. feedback. department_id = d.department_id.department_name FROM employees e JOIN departments d USING (e.department_name FROM employees e NATURAL JOIN departments d.department_id). d.department_id.department_id = d.last_name.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e. SELECT e.department_id.last_name. d. .department_id). Which query will retrieve all the rows in the EMPLOYEES table.department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_id = d. d. (*) SELECT e. d.last_name.department_id). e.42. e. even if there is no match in the DEPARTMENTS table? Mark for Review (1) Points SELECT e.department_id. e.last_name. e. SELECT e. Which statement about the GROUP BY clause is true? Mark for Review . 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.Correct 43. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. 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. (*) The last column listed in the GROUP BY clause is the most major grouping. Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly.(1) Points The first 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. You cannot use a column alias in the GROUP BY clause. The department id is not listed in the departments table. 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.The GROUP BY clause must have something to GROUP. COUNT(*) FROM employees GROUP BY job_id. What will the following SQL Statement do? SELECT job_id. (*) Displays only the number of job_ids. . Displays all the jobs with as many people as there are jobs. Correct 46. Correct 47. department_id FROM employees GROUP BY department_id. Evaluate this SELECT statement: SELECT MIN(hire_date). Correct . The latest hire date in the EMPLOYEES table. Which values are displayed? Mark for Review (1) Points The earliest hire date in each department. The hire dates in the EMPLOYEES table that contain NULL values. (*) The the earliest hire date in the EMPLOYEES table. Which group function will you use? Mark for Review (1) Points MAX . You need to compute the total salary for all employees in department 10. 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.Section 5 Lesson 2 (Answer all questions in this section) 48. SUM (*) VARIANCE COUNT Incorrect. 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 . Refer to Section 5 50. Section 5 Lesson 2 (Answer all questions in this section) 51.Database Programming with SQL Review your answers. An asterisk (*) indicates a correct answer. and question scores below. feedback. 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 5 of 10 Test: Mid Term Exam . 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.VAR_SAMP VARIANCE Correct 52. The VENDORS table contains these columns: VENDOR_ID NUMBER Primary Key . NAME VARCHAR2(30) LOCATION_ID NUMBER ORDER_DT DATE ORDER_AMOUNT NUMBER(8. Refer to Section 5 .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. An error occurs. The values in the PROD_PRICE column and the PROD_QTY column are averaged together. 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 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. (*) .54. February and March of 2003.00 89453485 8549038 15-FEB-03 INTEREST 596. 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'.00 85490345 5489304 20-MAR-03 BASIC 568. (*) SELECT AVG(payment_amount) FROM payment.Correct 55.00 You need to determine the average payment amount made by each customer in January. Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859. SELECT SUM(payment_amount) . 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 . SELECT AVG(payment_amount) FROM payment WHERE TO_CHAR(payment_date) IN (JAN.FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'. The statement will return the greatest value in the INVENTORY table.00 890890 LOAFER 89789 14. (*) Correct 57. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not null.00 857689 HEEL 85940 11. The statement will return the total number of rows in the AMOUNT column.00 809090 LOAFER 89098 10.00 758960 SANDAL 86979 You issue this SELECT statement: .00 968950 SANDAL 85909 10. The statement will replace all NULL values that exist in the AMOUNT column.00 869506 SANDAL 89690 15. . Which statement about the COUNT function is true? Mark for Review (1) Points The COUNT function ignores duplicates by default. Which value is displayed? Mark for Review (1) Points 0 6 7 (*) The statement will NOT execute successfully.SELECT COUNT(category) FROM styles. Correct 58. Evaluate this SELECT statement: SELECT COUNT(*) FROM products. Correct 59.The COUNT function always ignores null values by default. The COUNT function can be used to determine the number of unique. . Which statement is true? Mark for Review (1) Points The number of rows in the table is displayed. An error occurs because no WHERE clause is included in the SELECT statement. non-null values in a column. (*) The COUNT function can be used to find the maximum value in each column. An error occurs due to an error in the SELECT clause. (*) The number of unique PRODUCT_IDs in the table is displayed. 00.Incorrect. Refer to Section 5 Section 6 Lesson 1 (Answer all questions in this section) 60. The extended cost of each item equals the quantity value multiplied by the cost value. 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. Which SQL statement will display the desired result? Mark for Review (1) Points .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 GROUP BY category_id. location_id. (*) SELECT SUM(cost * quantity) TOTAL FROM products WHERE price < 25.00 GROUP BY location_id. location_id FROM products WHERE price < 25.00 GROUP BY category_id. SELECT category_id.00.location_id FROM products WHERE price > 25.SELECT category_id. location_id FROM products WHERE price < 25. SUM(cost * quantity) TOTAL. location_id. . SELECT SUM(cost * quantity) TOTAL. SUM(cost * quantity) TOTAL. feedback. (*) .Database Programming with SQL Review your answers. An asterisk (*) indicates a correct answer. 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. Section 6 Lesson 1 (Answer all questions in this section) 61. you should use a WHERE clause.Correct Page 6 of 10 Test: Mid Term Exam . and question scores below. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. You must use the HAVING clause with the GROUP BY clause. (*) .You can use a column alias in a GROUP BY clause. rows are not sorted when a GROUP BY clause is used. Correct 62. By default. 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. Evaluate this SELECT statement: SELECT SUM(salary). SELECT location_id.SELECT location_id. manager_id. based on a group function? . COUNT(DISTINCT type) FROM manufacturer. manager_id FROM employees GROUP BY department_id. COUNT(type) FROM manufacturer GROUP BY location_id. Which SELECT statement clause allows you to restrict the rows returned. department_id. Correct 63. COUNT(DISTINCT type) FROM manufacturer GROUP BY type. SELECT location_id. 000. 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. . 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.Mark for Review (1) Points HAVING SUM(salary) > 100000 (*) WHERE SUM(salary) > 100000 WHERE salary > 100000 HAVING salary > 100000 Correct 64. SELECT employee_id.Which of the following SELECT statements will accomplish this task? Mark for Review (1) Points SELECT employee_id. (*) . salary FROM employees WHERE salary > 40000 AND hire_date = (SELECT hire_date FROM employees WHERE (sysdate-hire_date) / 365 > 1). salary FROM employees WHERE salary > 40000 AND hire_date = (SELECT hire_date FROM employees WHERE (sysdate-hire_date) / 365 > 1). last_name. hire_date. salary FROM employees WHERE salary > 40000 AND (sysdate-hire_date) / 365 > 1. last_name. SELECT employee_id. last_name. hire_date. salary FROM employees WHERE salary > 40000 AND hire_date IN (sysdate-hire_date) / 365 > 1). Refer to Section 6 65.SELECT employee_id. last_name. Incorrect. 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 . Evaluate this SELECT statement: .ORDER BY SELECT FROM WHERE GROUP BY HAVING ORDER BY (*) SELECT FROM WHERE HAVING ORDER BY GROUP BY Correct 66. The EMPLOYEES table contains these columns: ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER .SELECT COUNT(employee_id). 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. department_id FROM employees GROUP BY department_id. You only want to include employees who earn more than 15000. The SALARY column is NOT included in the GROUP BY clause. The WHERE clause contains a syntax error. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. (*) Incorrect. name.SALARY NUMBER (7. The HIRE_DATE column is NOT included in the GROUP BY clause. hire_date. name ORDER BY hire_date. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing.2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. Refer to Section 6 . department_id. id_number. 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? .Section 6 Lesson 2 (Answer all questions in this section) 68. total FROM ORDERS (SELECT employee_id FROM employees WHERE last_name = 'Franklin') WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01'. (*) . employee_id. 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' AND emp_id = 'Franklin'. total FROM ORDERS WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01'.Mark for Review (1) Points 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'. SELECT order_id. SELECT order_id. 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. Refer to Section 6 69.) Mark for Review (1) Points (Choose all correct answers) SELECT * FROM class_assignments . Which two SQL statements correctly use subqueries? (Choose two.Incorrect. WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments). 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). (*) SELECT * FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0). . (*) SELECT * FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963). Refer to Section 6 Page 7 of 10 . 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 70.Incorrect. Database Programming with SQL Review your answers. Section 6 Lesson 2 (Answer all questions in this section) 71. An asterisk (*) indicates a correct answer. and question scores below.Test: Mid Term Exam . feedback. 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 . SELECT AVG(cost). You need to create a report to display the names of products with a cost value greater than the average cost of all products. (*) SELECT product_name FROM products WHERE cost > AVG(cost).72. 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). . Which SELECT statement should you use? Mark for Review (1) Points SELECT product_name FROM products WHERE cost > (SELECT AVG(cost) FROM product). Which statement about the <> operator is true? Mark for Review (1) Points The <> operator is NOT a valid SQL operator. The <> operator can be used when a single-row subquery returns only one row. The <> operator CANNOT be used in a single-row subquery. The <> operator returns the same result as the ANY operator in a subquery.Correct Section 6 Lesson 3 (Answer all questions in this section) 73. (*) Correct . 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. 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').74. However. you are not sure which supervisor ID belongs to Brad Carter. SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id . (*) Incorrect. SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id FROM supervisors WHERE last_name = 'Carter'). Refer to Section 6 . SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter').FROM employees WHERE last_name = 'Carter'). 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. job_id FROM employees WHERE department_id IN (SELECT department_id . What will the following SQL statement display? SELECT department_id. Refer to Section 6 Section 6 Lesson 4 (Answer all questions in this section) 76. last_name. You are looking for Executive information using a subquery. last name. The department ID. Mark for Review (1) Points The department ID. department name and last name for every employee in the Executive department. A multiple-row operator expects how many values? Mark for Review (1) Points One or more (*) Only one Two or more . The department ID. last name. job ID from departments for Executive employees. (*) Correct 77. last name. The department ID.FROM departments WHERE department_name = 'Executive'). job ID for every employee in the Executive department. department name for every Executive in the employees table. (*) All the rows in the table would be selected.00). . No rows would be returned by the outer query.None Correct 78. name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. Evaluate this SELECT statement: SELECT customer_id. What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. Only the rows with CUSTOMER_ID values equal to null would be selected. Which operator or keyword cannot be used with a multiple-row subquery? Mark for Review (1) Points ALL ANY = (*) > Correct 80. Correct 79. Examine the structures of the PARTS and MANUFACTURERS tables: PARTS: PARTS_ID VARCHAR2(25) PK PARTS_NAME VARCHAR2(50) . 'DALLAS ')).15 WHERE manufacturers_id = (SELECT id FROM manufacturers WHERE UPPER(location) IN('ATLANTA '.MANUFACTURERS_ID NUMBER COST 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. SELECT parts_name.2) PRICE NUMBER(5. 'BOSTON '. cost FROM parts WHERE manufacturers_id != (SELECT id FROM manufacturers . price. id = p.manufacturers_id)).WHERE LOWER(name) = 'cost plus'). SELECT parts_name. Correct Page 8 of 10 . price. cost FROM parts WHERE manufacturers_id IN (SELECT id FROM manufacturers m JOIN part p ON (m. (*) SELECT parts_name FROM (SELECT AVG(cost) FROM manufacturers) WHERE cost > AVG(cost). An asterisk (*) indicates a correct answer.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. and question scores below. feedback.Test: Mid Term Exam . Section 6 Lesson 4 (Answer all questions in this section) 81. payment_type . Examine the data in the PAYMENT table: PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT 86590586 8908090 10-JUN-03 BASIC 859.Database Programming with SQL Review your answers. Incorrect. Refer to Section 6 82. Remove the parentheses surrounding the nested SELECT statement. 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.FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003'). Change the comparison operator to a single-row operator. Which statement about the ANY operator when used with a multiple-row subquery is true? Mark for Review (1) Points . (*) The ANY operator can be used with the DISTINCT keyword. The ANY operator can be used with the LIKE and IN operators. name FROM players WHERE team_id IN (SELECT team_id FROM teams WHERE team_id > 300 AND salary_cap > 400000).The ANY operator compares every value returned by the subquery. 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. Evaluate this SELECT statement: SELECT player_id. Incorrect. Refer to Section 6 83. The ANY operator is a synonym for the ALL operator. (*) . first_name FROM customer WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). A syntax error in the inner query would be returned. Incorrect. The results of the inner query are returned to the outer query. Which statement is true about the given subquery? Mark for Review (1) Points The outer query executes before the nested subquery. All the rows in the PLAYER table would be returned by the outer query. Evaluate this SELECT statement that includes a subquery: SELECT last_name. (*) . Refer to Section 6 84.A syntax error in the outer query would be returned. Both the inner and outer queries must return a value.An error occurs if the either the inner or outer queries do not return a value. or an error occurs. Correct 86. Multiple-row subqueries can be used with both single-row and multiple-row operators. 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. Multiple-row subqueries can only be used in SELECT statements. (*) Single-row operators can be used with both single-row and multiple-row subqueries. 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 . <. 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.IN. ANY..2) QTY_IN_STOCK NUMBER(4) . =..AND. and > Correct Section 7 Lesson 1 (Answer all questions in this section) 87. and ALL (*) LIKE BETWEEN.. 'Cable'.04. 7.09.LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE Which INSERT statement will execute successfully? Mark for Review (1) Points INSERT INTO products VALUES (2958. 7. (*) INSERT INTO products VALUES (2958. 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: . SYSDATE). INSERT INTO products(product_id. product_name) VALUES (2958. 4. 8690. Correct 88. 4. INSERT INTO products(product_id. 8690. 8690. 'Cable').04. SYSDATE). supplier_id VALUES (2958. 700). product_name. 'Cable'.09. 'Cable'. The row was created with the correct data in one of the three columns. Correct .'6-foot nylon leash'. 10).(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. (*) The row was created with the correct data in two of three columns. 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 completely wrong. No data ended up in the correct columns. you should not add an amount to the CREDIT column. Use the ON clause Omit the column in the column list. how can you implicitly insert a null value in a column? Mark for Review (1) Points Use the NULL keyword. You have been instructed to add a new customer to the CUSTOMERS table. Using the INSERT statement. and assuming that a column can accept null values. Correct 90.89. 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? . (*) It is not possible to implicitly insert a null value in a column. Because the new customer has not had a credit check. 'tflanders'. (*) INSERT INTO customers VALUES (cust_id. null. 'InterCargo'. 'samerica'). InterCargo. (*) INSERT INTO customers VALUES (200. location) VALUES (200. poc. 'InterCargo'. location) (200. tflanders. 'samerica'). 'InterCargo'. 'samerica'). poc.Mark for Review (1) Points (Choose all correct answers) INSERT INTO customers (cust_id. 'tflanders'. 0. INSERT INTO customers VALUES (200. Correct . 'tflanders'. company. 0. samerica). credit. company. You need to update the area code of employees that live in Atlanta . and question scores below. feedback. An asterisk (*) indicates a correct answer.Database Programming with SQL Review your answers. Section 7 Lesson 2 (Answer all questions in this section) 91.Page 9 of 10 Test: Mid Term Exam . 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? . Incorrect. (*) An error message would be returned.Mark for Review (1) Points UPDATE city = Atlanta. . (*) LIKE 'At%'. Refer to Section 7 92. WHERE city = 'Atlanta'. Only one row would be deleted. No rows would be deleted. 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. SET city = 'Atlanta'. 'TN'. 37777. Incorrect. 'Smith'. 'J.. Nashville. J. '37777'). Which of the following represents the correct syntax for an INSERT statement? Mark for Review (1) Points INSERT VALUES INTO customers (3178 J.Correct 93.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777'. 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) . TN. (*) INSERT customers VALUES 3178. INSERT INTO customers VALUES '3178' 'J. 'Nashville'. Refer to Section 7 94. '123 Main Street'. Smith 123 Main Street Nashville TN 37777. 123 Main Street. Smith.'. INSERT INTO customers VALUES (3178. HIRE_DATE DATE SALARY NUMBER(9. all employees in department 10 have the same salary value.2) BONUS NUMBER(9. (*) . UPDATE employees SET salary = (SELECT salary FROM employees WHERE employee_id = 89898).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. Which statement should you execute? Mark for Review (1) Points UPDATE employees SET salary = SELECT salary FROM employees WHERE employee_id = 89898. Currently. 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. Which clause should you include in the UPDATE statement to update multiple columns? Mark for Review . You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES table using one UPDATE statement. 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. Refer to Section 7 95. has informed you that she was recently married. 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 the USING clause the ON clause the WHERE clause the SET clause (*) Correct 97. and she has requested that you update her name in the employee database. Janet Roper. Janet is the only person with the last name of Roper that is employed by the company. One of the sales representatives. Her new last name is Cooper. UPDATE employees SET cooper = 'last_name' WHERE last_name = 'roper'. Refer to Section 7 . (*) UPDATE employees last_name = 'cooper' WHERE last_name = 'roper'. Incorrect. UPDATE employees SET last_name = 'roper' WHERE last_name = 'cooper'.(1) Points UPDATE employees SET last_name = 'cooper' WHERE last_name = 'roper'. 125 WHERE team_id = 5960. UPDATE players SET salary = salary * .125 WHERE team_id = 5960. 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. Correct .125) WHERE team_id = 5960. Which statement should you use? Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1.5 percent. UPDATE players SET salary = salary * 1. The TEAM_ID value for the Tiger team is 5960.2) You need to increase the salary of each player for all players on the Tiger team by 12. (*) UPDATE players (salary) VALUES(salary * 1.98.125. DELETE * FROM employees WHERE employee_id = 348. what is the result? Mark for Review (1) Points . You need to delete a record in the EMPLOYEES table for Tim Jones. When the WHERE clause is missing in a DELETE statement. whose unique employee identification number is 348. Refer to Section 7 100. (*) DELETE FROM employees WHERE last_name = jones. DELETE 'jones' FROM employees. 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.99. Incorrect. An error message is displayed indicating incorrect syntax.All rows are deleted from the table. Incorrect. Nothing. The statement will not execute. (*) The table is removed from the database. Refer to Section 7 Page 10 of 10 Test: Mid Term Exam .Database Programming with SQL . '$')SALARY FROM employees. 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. and question scores below.Review your answers. What will the following SQL statement display? SELECT last_name. leftpadded with the $ and the column labeled SALARY. 15. An asterisk (*) indicates a correct answer." Correct . Section 1 Lesson 1 (Answer all questions in this section) 1. (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. size of 15 and the column labeled SALARY. feedback. LPAD(salary. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value. 2. and date column values? Mark for Review . You issue this SQL statement: SELECT INSTR ('organizational sales'. 'al') FROM dual. Which functions can be used to manipulate character. number. Which value is returned by this command? Mark for Review (1) Points 1 2 13 (*) 17 Correct 3. and INITCAP ROUND.00 .00 968950 SANDAL 85909 10. Refer to Section 1 4.00 890890 LOAFER 89789 14. RPAD.00 758960 SANDAL 86979 12. and TRIM (*) UPPER. LOWER. TRUNC. TRUNC.00 809090 LOAFER 89098 10.00 869506 SANDAL 89690 15. and ADD_MONTHS Incorrect.00 857689 HEEL 85940 11. and MOD ROUND. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.(1) Points CONCAT. 2.2) FROM styles WHERE style_id = 895840.You query the database and return the value 79. SELECT SUBSTR(category. Which script did you use? Mark for Review (1) Points SELECT INSTR(category. (*) . 2.2) FROM styles WHERE style_id = 758960. SELECT INSTR(category.2) FROM styles WHERE style_id = 895840. -2. -2.2) FROM styles WHERE style_id = 895840. SELECT SUBSTR(category. . 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.Correct 5. Correct 7. Which function should you use? Mark for Review (1) Points CASE UCASE UPPER (*) . (*) The maximum number of characters allowed in the EMAIL column. You need to display each employee's name in all uppercase letters.What will this SELECT statement display? Mark for Review (1) Points The longest e-mail address in the EMPLOYEES table. The number of characters for each value in the EMAIL column in the EMPLOYEES table. The email address of each employee in the EMPLOYEES table. .IN.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. IS NULL Correct .... 'MONTH') FROM employees. 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.9. Evaluate this function: MOD (25. (*) . Database Programming with SQL . Correct Page 1 of 10 Test: Mid Term Exam . 'MONTH') FROM employees. 'MI') FROM employees.SELECT ROUND(hire_date. 'MON') FROM employees. SELECT ROUND(hire_date. SELECT TRUNC(hire_date. feedback. and question scores below. 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.Review your answers. An asterisk (*) indicates a correct answer. The values returned by this SELECT statement will be of which data type? Mark for Review (1) Points . Section 1 Lesson 3 (Answer all questions in this section) 11. 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 . You want to create a report that displays all orders and their amounts that were placed during the month of January. SELECT orderid. Which query should you issue? Mark for Review (1) Points SELECT orderid.Correct 13. You want the orders with the highest amounts to appear first. total FROM orders WHERE order_date IN ( 01-jan-02 . total FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' ORDER BY total DESC. 31-jan-02 ) ORDER BY total. SELECT orderid. (*) . total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC. SELECT orderid. (*) SELECT last name. 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 DISPLAY WEEKS FROM employees WHERE department id = 90. total FROM orders WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02' ORDER BY total DESC. . (SYSDATE-hire_date)/7 AS WEEKS FROM employees WHERE department_id = 90. Correct 14. # of WEEKS FROM employees WHERE department_id = 90. (SYSDATE-hire_date)AS WEEK FROM employees WHERE department_id = 90.SELECT last_name. You need to subtract three months from the current date. Correct 15. SELECT last_name. Which function should you use? Mark for Review (1) Points ROUND TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN . Not all date functions return date values.Correct Section 2 Lesson 1 (Answer all questions in this section) 16.) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. (*) Number functions can return number or character values. (*) Single-row functions manipulate groups of rows to return one result per group of rows. . Which two statements concerning SQL functions are true? (Choose two. Conversion functions convert a value from one data type to another data type. TRIM . ADD_MONTHS LENGTH. Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . SUBSTR.Correct 17. LPAD. Which functions allow you to perform explicit data type conversions? Mark for Review (1) Points ROUND.TO_DATE('01-OCT-2004') (*) NEXT_DAY(hire_date) + 5 SYSDATE . TRUNC.6 SYSDATE + 30 / 24 Correct 18. 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 . Each employee's salary must be displayed in the following format: $000.000. NVL2. TO_DATE.TO_CHAR. 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. TO_NUMBER (*) NVL.00. NULLIF Correct 19. yyyy'). total FROM customers NATURAL JOIN orders WHERE total >= 2500. dd Month. TO_CHAR (sysdate. SELECT companyname. You have been asked to create a report that lists all customers who have placed orders of at least $2. 13 April. 'fmDay. The report's date should be displayed in the Day. TO_CHAR (sysdate. dy month. Tuesday. TO_DATE (date. TO_DATE (sysdate. 'day. Date Month. SELECT companyname. Year format (For example. dy month. SELECT companyname. yyyy'). dd month. Which statement should you issue? Mark for Review (1) Points SELECT companyname.20. total FROM customers NATURAL JOIN orders WHERE total >= 2500. total FROM customers NATURAL JOIN orders WHERE total >= 2500. yyyy'). yyyy'). (*) . 'dd. total FROM customers NATURAL JOIN orders WHERE total >= 2500.500. 'fmdd. 2004 ). (*) .30"? Mark for Review (1) Points SELECT TO_CHAR(price. feedback. An asterisk (*) indicates a correct answer.900.Correct Page 2 of 10 Test: Mid Term Exam .Database Programming with SQL Review your answers. Which SQL Statement should you use to display the prices in this format: "$00.99') FROM product. '$99. Section 2 Lesson 1 (Answer all questions in this section) 21. and question scores below. 99") FROM product.900. $99. "$99.SELECT TO_CHAR(price. SELECT TO_CHAR(price. 0) "Balance Due" FROM student_accounts. '$99. 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. When executed.99) FROM product.900. (*) . SELECT TO_CHAR(price.990.99') FROM product. Refer to Section 2 Section 2 Lesson 2 (Answer all questions in this section) 22. Incorrect. 0). 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 . SELECT TO_NUMBER(tuition_balance. 0). tutition_balance + housing_balance "Balance Due" FROM student_accounts. Correct 23.SELECT NVL(tuition_balance. TO_NUMBER (housing_balance. 0). tuition_balance + housing_balance "Balance Due" FROM student_accounts. NVL (housing_balance). SELECT tuition_balance + housing_balance FROM student_accounts. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12. cost.00 809090 LOAFER 89098 10.00 869506 SANDAL 89690 15.COALESCE (*) Correct 24.00 ORDER BY category.00 968950 SANDAL 85909 10. style_name.00 758960 SANDAL 86979 Evaluate this SELECT statement: SELECT style_id. 0) < 15. . category.00 857689 HEEL 85940 11. cost FROM styles WHERE style_name = 'SANDAL' AND NVL(cost.00 890890 LOAFER 89789 14. 00 968950 SANDAL 85909 10.00 869506 SANDAL 89690 15.00 .00 968950 SANDAL 85909 10.Which result will the query provide? Mark for Review (1) Points STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.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 758960 SANDAL 86979 STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85909 12. Refer to Section 2 Section 3 Lesson 2 (Answer all questions in this section) 25.STYLE_ID STYLE_NAME CATEGORY COST 968950 SANDAL 85909 10.00 758960 SANDAL 86979 (*) Incorrect.00 895840 SANDAL 85940 12. The PATIENTS and DOCTORS tables contain these columns: PATIENTS PATIENT_ID NUMBER(9) LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) . 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 . doctor_id FROM patients.DOCTORS DOCTOR_ID NUMBER(9) LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) You issue this statement: SELECT patient_id. doctors. 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 . When joining 3 tables in a SELECT statement.26. Which query should you issue to accomplish this task? Mark for Review (1) Points . (*) Incorrect.000 per year.a Cartesian product (*) Correct 28. The JOIN keyword must be included. The WHERE clause represents the join criteria. The FROM clause represents the join criteria. 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. You need to create a report that lists all employees in department 10 (Sales) whose salary is not equal to $25. Refer to Section 3 29. salary FROM employees WHERE salary > 25000 AND department_id = 10. first_name. SELECT last_name. first_name. first_name.SELECT last_name. SELECT last_name. salary FROM employees WHERE salary = 25000 AND department_id = 10. (*) Correct . SELECT last_name. first_name. salary FROM employees WHERE salary <= 25000 AND department_id = 10. salary FROM employees WHERE salary != 25000 AND department_id = 10. first_name. e.employee_id.first_name.department_id AND employees. Evaluate this SQL statement: SELECT e. e.department_id > 5000 (*) ORDER BY 4. Refer to Section 3 . Incorrect. d.last_name. d. departments d WHERE e. Which clause contains a syntax error? Mark for Review (1) Points SELECT e. e.department_id AND employees.department_name FROM employees e. departments d WHERE e.department_id = d.employee_id. e.last_name.department_id = d.30.department_id > 5000 ORDER BY 4.department_name FROM employees e. player_id) LEFT OUTER JOIN team t ON (p.manager_id = m. Section 3 Lesson 4 (Answer all questions in this section) 31.last_name.team_name FROM player p LEFT OUTER JOIN player m ON (p. Which join is evaluated first? .team_id = t. m. feedback. m. t.first_name. and question scores below.Page 3 of 10 Test: Mid Term Exam .Database Programming with SQL Review your answers. Evaluate this SELECT statement: SELECT p.team_id). An asterisk (*) indicates a correct answer.player_id. 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. The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of the ORDERS table. Which type of join should you use to display the data? Mark for Review (1) Points natural join self-join outer join (*) . Refer to Section 3 32. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you need to display. An outer join will return data only if both tables contain an identical pair of columns. (*) Incorrect. Refer to Section 3 33. 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. 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.equijoin Incorrect. Refer to Section 3 . An outer join will return only data from the far left column in one table and the far right column in the other table. The following SQL statement will produce what output? SELECT last_name. Refer to Section 4 35. department_name FROM employees CROSS JOIN departments. 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.Section 4 Lesson 2 (Answer all questions in this section) 34. Mark for Review (1) Points . (*) A cross referenced result omitting similar fields from the two tables. . (*) Columns with the same names must have compatible data types. The last_name and department name from the employee table. Which statement about a natural join is true? Mark for Review (1) Points Columns with the same names must have identical data types. A Cartesian product between the two tables. Correct 36. Columns with the same names cannot be included in the SELECT list of the query.The missing rows from the join condition. Columns with the same names must have the same precision and datatype. Refer to Section 4 38.Incorrect. Refer to Section 4 Section 4 Lesson 3 (Answer all questions in this section) 37. A join condition that includes the (+) on the left hand side. Below find the structure of the CUSTOMERS and SALES_ORDER tables: . A join that joins a table to itself Incorrect. 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. 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. 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. Which statement could you use? Mark for Review .CUSTOMERS CUSTOMER_ID NUMBER NOT NULL. customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id). SELECT c.customer_name FROM customers c WHERE c.customer_name FROM customers c. (*) SELECT c. Correct .customer_id (+) = s.(1) Points SELECT c.customer_id. sales_order s WHERE c.customer_id = s.customer_id(+). sales_order s WHERE c.customer_id FROM sales_order s).customer_id not in (SELECT s.customer_name FROM customers c. SELECT c. 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 . product_name. for all products that have a vendor assigned.vendor_id = v.vendor_name FROM products p LEFT OUTER JOIN vendors v ON p.vendor_name FROM products p .product_name. SELECT p. v.vendor_id ORDER BY p.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.product_name. Which two queries could you use? Mark for Review (1) Points (Choose all correct answers) SELECT p. v. including the product name and associated vendor name. v.product_name. Refer to Section 4 . SELECT p.product_name.vendor_name FROM products p JOIN vendors v USING (vendor_id) ORDER BY p. (*) Incorrect.product_name.JOIN vendors v ON (vendor_id) ORDER BY p.product_name. (*) SELECT p. SELECT p.product_name.product_name.vendor_name FROM products p JOIN vendors v USING (p.product_name. v. v.vendor_id) ORDER BY p.vendor_name FROM products p NATURAL JOIN vendors v ORDER BY p. feedback.Database Programming with SQL Review your answers. Section 4 Lesson 4 (Answer all questions in this section) 41. An asterisk (*) indicates a correct answer. and question scores below.Page 4 of 10 Test: Mid Term Exam . 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 . You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. 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. 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 . The EMPLOYEE_HISTS table will be the first table in the FROM clause. You need to join the EMPLOYEE_HISTS and EMPLOYEES tables.Correct 42. . What will the following SQL Statement do? SELECT job_id.an inner join a left outer join a right outer join (*) Correct Section 5 Lesson 1 (Answer all questions in this section) 44. Mark for Review (1) Points Displays all the employees and groups them by job. COUNT(*) FROM employees GROUP BY job_id. Displays all the jobs with as many people as there are jobs.Displays each job id and the number of people assigned to that job id. Correct 45. (*) The the earliest hire date in the EMPLOYEES table. . department_id FROM employees GROUP BY department_id. (*) Displays only the number of job_ids. Which values are displayed? Mark for Review (1) Points The earliest hire date in each department. Evaluate this SELECT statement: SELECT MIN(hire_date). Correct 46. A query that includes a group function in the SELECT list must include a GROUP BY clause. (*) Group functions can only be used in a SELECT list. Refer to Section 5 47. The hire dates in the EMPLOYEES table that contain NULL values. AVG (salary)"Average" .The latest hire date in the EMPLOYEES table. What is the best explanation as to why this SQL statement will NOT execute? SELECT department_id "Department". Incorrect. Which statement about group functions is true? Mark for Review (1) Points Group functions ignore null values. Group functions can be used in a WHERE clause. The department id is not listed in the departments table. (*) The GROUP BY clause must have something to GROUP. The CUSTOMERS table contains these columns: CUSTOMER_ID NUMBER(9) FIRST_NAME VARCHAR2(25) . Mark for Review (1) Points Salaries cannot be averaged as not all the numbers will divide evenly. Refer to Section 5 Section 5 Lesson 2 (Answer all questions in this section) 48.FROM employees GROUP BY Department. You cannot use a column alias in the GROUP BY clause. Incorrect. Which group function should you use to calculate this value? Mark for Review (1) Points AVG (*) SUM COUNT STDDEV Correct 49.LAST_NAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7. 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.2) CATEGORY VARCHAR2(20) You need to calculate the average credit limit for all the customers in each category. Which group function would you use to display the highest salary value in the EMPLOYEE table? Mark for Review (1) Points AVG . What happens when this statement is issued? Mark for Review . 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.COUNT MAX (*) MIN Correct 50. prod_qty) FROM products. (*) Correct Page 5 of 10 Test: Mid Term Exam .Database Programming with SQL .(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. Review your answers. ignore (*) each row. Mark for Review (1) Points a row set. and question scores below. Section 5 Lesson 2 (Answer all questions in this section) 51. You need to compute the total salary for all employees in department 10. Group functions return a value for ________________ and ________________ null values in their computations. include each row. feedback. An asterisk (*) indicates a correct answer. include Correct 52. Which group function will you use? Mark for Review (1) Points . ignore a row set. Which aggregate function can be used on a column of the DATE data type? Mark for Review (1) Points AVG MAX (*) STDDEV SUM Correct .MAX SUM (*) VARIANCE COUNT Correct 53. 54. model FROM trucks WHERE model = '4x4'. (*) SELECT AVG (price) FROM trucks WHERE model IS '4x4'. 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). Correct . SELECT AVG(price) FROM trucks WHERE model IS 4x4. 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.55. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for Review (1) Points SELECT COUNT(products). . (*) SELECT ROWCOUNT FROM products.SELECT COUNT FROM products. SELECT COUNT (*) FROM products. The total of the SALARY column for all employees that have a salary greater than 30000. Evaluate this SELECT statement: SELECT COUNT(*) FROM employees WHERE salary > 30000. The number of rows in the EMPLOYEES table that have a salary greater than 30000. (*) . Correct 57. Which results will the query display? Mark for Review (1) Points The number of employees that have a salary less than 30000. 00 869506 SANDAL 89690 15. Correct 58. Which value is displayed? Mark for Review .00 809090 LOAFER 89098 10. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 857689 HEEL 85940 11.00 890890 LOAFER 89789 14.00 968950 SANDAL 85909 10.00 758960 SANDAL 86979 You issue this SELECT statement: SELECT COUNT(category) FROM styles.The query generates an error and returns no results. 15 543949 349302 453235 4. Refer to Section 5 59.50 You query the LINE_ITEM table and a value of 3 is returned. Which SQL statement did you execute? Mark for Review .05 867950 985490 945809 5.60 0. Incorrect.25 0.60 954039 439203 438925 5.10 768385 862459 849869 5.99 0. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT 890898 847589 848399 8.(1) Points 0 6 7 (*) The statement will NOT execute successfully. (*) SELECT COUNT(*) FROM line_item. Incorrect. 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. SELECT AVG(discount) FROM line_item. Refer to Section 5 Section 6 Lesson 1 (Answer all questions in this section) 60.(1) Points SELECT COUNT(discount) FROM line_item. 2003 ? . SELECT SUM(discount) FROM line_item. SELECT customer_id. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-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 COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. AVG(salary) FROM employees .Correct Page 6 of 10 Test: Mid Term Exam .Database Programming with SQL Review your answers. Section 6 Lesson 1 (Answer all questions in this section) 61. An asterisk (*) indicates a correct answer. feedback. and question scores below. Evaluate this statement: SELECT department_id. department_id HAVING AVG(salary) > 35000 ORDER BY department_id.WHERE job_id <> 69879 GROUP BY job_id. department_id . department_id HAVING AVG(salary) > 35000 (*) Correct 62. Which clauses restricts the result? Choose two. Evaluate this SELECT statement: SELECT COUNT(employee_id). Mark for Review (1) Points (Choose all correct answers) SELECT department_id. AVG(salary) WHERE job_id <> 69879 (*) GROUP BY job_id. FROM employees GROUP BY department_id. The MANUFACTURER table contains these columns: MANUFACTURER_ID NUMBER MANUFACTURER_NAME VARCHAR2(30) TYPE VARCHAR2(25) LOCATION_ID NUMBER . 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. You only want to include employees who earn more than 15000. COUNT(DISTINCT type) FROM manufacturer GROUP BY location_id. COUNT(type) FROM manufacturer GROUP BY location_id.You need to display the number of unique types of manufacturers at each location. . COUNT(DISTINCT type) FROM manufacturer GROUP BY type. SELECT location_id. COUNT(DISTINCT type) FROM manufacturer. (*) SELECT location_id. SELECT location_id. Which SELECT statement should you use? Mark for Review (1) Points SELECT location_id. 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 .Incorrect. Refer to Section 6 64. The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8.GROUP BY HAVING ORDER BY (*) SELECT FROM WHERE HAVING ORDER BY GROUP BY Correct 65.2) . Primary Key LAST_NAME VARCHAR2 (30) NOT NULL FIRST_NAME VARCHAR2 (25) NOT NULL .) Mark for Review (1) Points (Choose all correct answers) ORDER BY AVG(salary) (*) GROUP BY MAX(salary) SELECT AVG(NVL(salary.Which two clauses represent valid uses of aggregate functions? (Choose three. The PLAYERS and TEAMS tables contain these columns: PLAYERS PLAYER_ID NUMBER NOT NULL. 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Correct 66. player_id) FROM players p.player_id) FROM players p.team_id) WHERE UPPER(p.team_id) WHERE UPPER(p. COUNT(p.team_id = t.team_name.team_name.team_id = t. 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. COUNT(p. SELECT t. Which SELECT statement will produce the desired result? Mark for Review (1) Points SELECT t.team_name. SELECT t. COUNT(p.team_id = t.team_name.player_id) FROM players JOIN teams t ON (p.team_id) .position) = 'GOAL KEEPER' HAVING COUNT(p. teams t ON (p.position) = 'GOAL KEEPER' GROUP BY t.player_id) > 3. teams t ON (p.TEAM_ID NUMBER POSITION VARCHAR2 (25) TEAMS TEAM_ID NUMBER NOT NULL. manager_id FROM employees GROUP BY department_id.team_id) WHERE UPPER(p. Which SELECT statement clause allows you to restrict the rows returned. SELECT t.player_id) > 3.WHERE UPPER(p. COUNT(p.team_name HAVING COUNT(p.team_id = t. (*) Incorrect.position) = 'GOAL KEEPER' GROUP BY t.team_name HAVING COUNT(p.player_id) FROM players p JOIN teams t ON (p. Evaluate this SELECT statement: SELECT SUM(salary). Refer to Section 6 67. manager_id.player_id) > 3.position) = 'GOAL KEEPER' GROUP BY t. based on a group function? Mark for Review (1) Points HAVING SUM(salary) > 100000 (*) .team_name. department_id. Which comparison operator should you use? Mark for Review (1) Points = > <= . You need to display all the players whose salaries are greater than or equal to John Brown's salary.WHERE SUM(salary) > 100000 WHERE salary > 100000 HAVING salary > 100000 Correct Section 6 Lesson 2 (Answer all questions in this section) 68. (*) Subqueries generally execute last. Which operator can be used with a multiple-row subquery? Mark for Review (1) Points IN (*) .>= (*) Correct 69. Subqueries cannot contain group functions. after the main or outer query executes. Which statement about subqueries is true? Mark for Review (1) Points Subqueries should be enclosed in double quotation marks. Subqueries are often used in a WHERE clause to return values for an unknown conditional value. Correct 70. An asterisk (*) indicates a correct answer. feedback.Database Programming with SQL Review your answers. .<> = LIKE Correct Page 7 of 10 Test: Mid Term Exam . and question scores below. 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. Examine the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8.Section 6 Lesson 2 (Answer all questions in this section) 71. .2) OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. You need to display all the orders that were placed on the same day as order number 25950. (*) Correct 72.You need to display all the orders that were placed on a certain date. 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 . 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) . Refer to Section 6 74. Which comparison operator is best used with a single-row subquery? Mark for Review (1) Points ANY ALL <> (*) IN Incorrect.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. 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'). you are not sure which supervisor ID belongs to Brad Carter. However. SELECT * FROM supervisors WHERE supervisor_id = . SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). (*) Incorrect. If a single-row subquery returns a null value and uses the equality comparison operator. SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter'). Refer to Section 6 75. what will the outer query return? Mark for Review (1) Points no rows (*) all the rows in the table .(SELECT employee_id FROM supervisors WHERE last_name = 'Carter'). 00 89453485 8549038 15-FEB-03 INTEREST 596.00 85490345 5489304 20-MAR-03 BASIC 568. 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 This statement fails when executed: SELECT customer_id.a null value an error Correct Section 6 Lesson 4 (Answer all questions in this section) 76. payment_type FROM payment WHERE payment_id = . 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 parentheses surrounding the nested SELECT statement. Correct 77. Change the comparison operator to a single-row operator. (*) Remove the quotes surrounding the date value in the OR clause.(SELECT payment_id FROM payment WHERE payment_amount = 596. 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 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 . new_dept_id FROM depart_hist WHERE old_dept_id = 15) AND new_dept_id = 10. last_name. Which query should you use? Mark for Review (1) Points SELECT employee_id.You want to generate a list of employees who are in department 10. first_name. SELECT employee_id. department_id FROM employee WHERE (employee_id) IN (SELECT employee_id FROM employee_hist WHERE old_dept_id = 15). department_id FROM employee WHERE (employee_id. first_name. first_name. (*) SELECT employee_id. department_id) = . department_id FROM employee WHERE (employee_id. last_name. but used to be in department 15. department_id) IN (SELECT employee_id. last_name. new_dept_id FROM depart_hist WHERE new_dept_id = 15). Correct 79. dept_id FROM employee WHERE old_dept_id = 15). 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 . SELECT employee_id.(SELECT employee_id. first_name. department_id) IN (SELECT employee_id. department_id FROM employee WHERE (employee_id. last_name. 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).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). . An asterisk (*) indicates a correct answer. Section 6 Lesson 4 (Answer all questions in this section) 81. and question scores below. feedback.All of the above. (*) Correct Page 8 of 10 Test: Mid Term Exam .Database Programming with SQL Review your answers. A multiple-row operator expects how many values? Mark for Review (1) Points . payment_amount FROM payment WHERE payment_id = . customer_id.One or more (*) Only one Two or more None Correct 82.00 85490345 5489304 20-MAR-03 BASIC 568.00 This statement fails when executed: SELECT payment_date. 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. Change the outer query WHERE clause to 'WHERE payment_id IN'.00). (*) Include the PAYMENT_ID column in the select list of the outer query. Evaluate this SELECT statement: SELECT customer_id. Correct 83. Remove the single quotes around the date value in the inner query WHERE clause. Which change could correct the problem? Mark for Review (1) Points Remove the subquery WHERE clause. name FROM customer WHERE customer_id IN (SELECT customer_id .(SELECT payment_id FROM payment WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500. No rows would be returned by the outer query.FROM customer WHERE state_id = 'GA' AND credit_limit > 500. What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned.00). (*) All the rows in the table 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. Only the rows with CUSTOMER_ID values equal to null would be selected. . You need to display all the products that cost more than the maximum cost of every product produced in Japan.Multiple-row subqueries can be used with both single-row and multiple-row operators. Correct 85. Which multiple-row comparison operator could you use? Mark for Review (1) Points >ANY (*) NOT=ALL IN >IN Correct . Multiple-row subqueries can only be used in SELECT statements. AND. =.. and > Correct Section 7 Lesson 1 (Answer all questions in this section) 87..86. which comparison operator(s) can you use? Mark for Review (1) Points IN. You need to create a SELECT statement that contains a multiple-row subquery. 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 . <. and ALL (*) LIKE BETWEEN. ANY... into the new table. (*) An error occurs because the FT_STUDENTS table already exists. An error occurs because you CANNOT use a subquery in an INSERT statement. named FT_STUDENTS.STU_TYPE_ID VARCHAR2(1) NOT NULL ENROLL_DATE DATE You create another table. An error occurs because the INSERT statement does NOT contain a VALUES clause. enroll_date FROM students WHERE UPPER(stu_type_id) = 'F'). stu_type_id. 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. last_name. first_name. with an identical structure. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id.You want to insert all fulltime students. who have a STU_TYPE_ID value of "F". Correct . dob. 09. 'Cable'). (*) INSERT INTO products VALUES (2958.04. 'Cable'.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'. 7.2) COST NUMBER (5. . 4. 700). SYSDATE).04.88. 8690. SYSDATE). 8690. The PRODUCTS table contains these columns: PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7. 'Cable'. INSERT INTO products(product_id. 8690. product_name. supplier_id VALUES (2958.09. INSERT INTO products(product_id. 4. 7. product_name) VALUES (2958. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. 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 . 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.Correct 89. No data ended up in the correct columns. Refer to Section 7 . (*) The row was created with the correct data in two of three columns.'6-foot nylon leash'. 10). The row was created with the correct data in one of the three columns. The row was created completely wrong. Incorrect.(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. 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. Which two commands can be used to create new rows? Mark for Review (1) Points INSERT. CREATE INSERT. MERGE (*) . CREATE MERGE. You want to enter a new record into the CUSTOMERS table.Database Programming with SQL Review your answers. An asterisk (*) indicates a correct answer. feedback. Section 7 Lesson 2 (Answer all questions in this section) 91. and question scores below.Page 9 of 10 Test: Mid Term Exam . 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. (*) . UPDATE Correct 92.10. bonus = bonus * 1. 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.2) BONUS NUMBER(9.INSERT.2) You need to increase the salary for all employees in department 10 by 10 percent.15 WHERE department_id = 10. 10) SET (bonus = bonus * 1.15 WHERE department_id = 10. .15 WHERE department_id = 10. Evaluate this statement: DELETE FROM customer.UPDATE employees SET salary = salary * 1. UPDATE employees SET salary = salary * .10 AND bonus = bonus * 1. 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. Incorrect. bonus = bonus * . UPDATE employees SET (salary = salary * 1.10. Refer to Section 7 93.15) WHERE department_id = 10. 2) .The statement deletes the first row in the CUSTOMERS table. 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. The statement removes the structure of the CUSTOMER table from the database. Examine the structures of the PRODUCTS and SUPPLIERS tables: SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. Correct 94. 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. 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').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. . (*) 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'). what is the result? Mark for Review (1) Points All rows are deleted from the table. (*) The table is removed from the database. The statement will not execute. Nothing. Correct 95. . An error message is displayed indicating incorrect syntax. When the WHERE clause is missing in a DELETE statement. You need to update the expiration date of products manufactured before June 30th. No rows would be deleted. 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. Only one row would be deleted. In which clause of the UPDATE statement will you specify this condition? Mark for Review (1) Points the ON clause the WHERE clause (*) . Correct 97. (*) An error message would be returned.Correct 96. the SET clause the USING clause Correct 98.2) MANAGERS MANAGER_ID NUMBER Primary Key LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) TEAM_ID NUMBER TEAMS . 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. Examine the structures of the PLAYERS.2) SALARY NUMBER(9. You need to remove a row from the EMPLOYEES table. and their team name for all teams with a id value greater than 5000 Correct 99. their manager. Which statement would you use? Mark for Review (1) Points .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. 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. 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.UPDATE with a WHERE clause INSERT with a WHERE clause DELETE with a WHERE clause (*) MERGE with a WHERE clause Correct 100. Which statement should you execute? Mark for Review (1) Points . all employees in department 10 have the same salary value. Currently. (*) UPDATE employees SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id = 10). Refer to Section 7 . 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. Incorrect.UPDATE employees SET salary = SELECT salary FROM employees WHERE employee_id = 89898. An asterisk (*) indicates a correct answer. feedback. Section 1 Lesson 1 (Answer all questions in this section) 1. . 4))) "Default Password" FROM employees.Database Programming with SQL Review your answers. You query the database with this SQL statement: SELECT CONCAT(last_name. (SUBSTR(LOWER(first_name).Page 10 of 10 Test: Mid Term Exam . and question scores below. 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 .Which function will be evaluated first? Mark for Review (1) Points CONCAT SUBSTR LOWER (*) All three will be evaluated simultaneously. The number of characters for each value in the EMAIL column in the EMPLOYEES table. . Evaluate this SELECT statement: SELECT LENGTH(email) FROM employees.SUBSTR (*) CONCAT Correct 3. (*) The maximum number of characters allowed in the EMAIL column. 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. What will the following SQL statement display? SELECT last_name.Correct 4. Refer to Section 1 ." Incorrect. '$')SALARY FROM employees. The last name and salary for all employees with the format of the salary 15 characters long. size of 15 and the column labeled SALARY. leftpadded with the $ and the column labeled SALARY. LPAD(salary. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value. 15. 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 query will result in an error: "ORA-00923: FROM keyword not found where expected. LOWER (*) Correct 6. 1. 5) "ID" FROM employee. CONCAT LOWER. In which order are the functions evaluated? Mark for Review (1) Points LOWER. CONCAT. SUBSTR SUBSTR. SUBSTR. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. SUBSTR. The STYLES table contains this data: . LOWER CONCAT.5. first_name)). CONCAT. SELECT INSTR(category.00 968950 SANDAL 85909 10.00 809090 LOAFER 89098 10.00 758960 SANDAL 86979 12.00 869506 SANDAL 89690 15. . -2.00 857689 HEEL 85940 11. Which script did you use? Mark for Review (1) Points SELECT INSTR(category.2) FROM styles WHERE style_id = 895840. 2.00 You query the database and return the value 79.00 890890 LOAFER 89789 14.STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.2) FROM styles WHERE style_id = 895840. -2. (*) Correct 7.2) FROM styles WHERE style_id = 758960.SELECT SUBSTR(category. Which function should you use? Mark for Review (1) Points CASE UCASE UPPER (*) TOUPPER . You need to display each employee's name in all uppercase letters. SELECT SUBSTR(category.2) FROM styles WHERE style_id = 895840. 2. Which comparison operator retrieves a list of values? Mark for Review (1) Points IN (*) LIKE BETWEEN.IN..Correct Section 1 Lesson 2 (Answer all questions in this section) 8. IS NULL Incorrect... Refer to Section 1 Lesson 1 .. Evaluate this function: MOD (25.367.9.3 Correct 10. 2) Which value is returned? Mark for Review (1) Points .-1) FROM dual. You issue this SQL statement: SELECT TRUNC(751. Which value does this statement display? Mark for Review (1) Points 700 750 (*) 751 751. 1 (*) 2 25 0 Correct Page 1 of 10 Test: Mid Term Exam . An asterisk (*) indicates a correct answer. feedback.Database Programming with SQL Review your answers. Section 1 Lesson 3 (Answer all questions in this section) . and question scores below. 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: . 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.11. Which function should you use? Mark for Review (1) Points ROUND . The values returned by this SELECT statement will be of which data type? Mark for Review (1) Points DATE (*) NUMBER DATETIME INTEGER Incorrect. You need to subtract three months from the current date. Refer to Section 1 13.SELECT hire_date + eval_months FROM employees. total FROM orders WHERE order_date IN ( 01-jan-02 . 31-jan-02 ) ORDER BY total.TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN Incorrect. You want the orders with the highest amounts to appear first. SELECT orderid. Which query should you issue? Mark for Review (1) Points SELECT orderid. . You want to create a report that displays all orders and their amounts that were placed during the month of January. Refer to Section 1 14. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC. Incorrect. (*) SELECT orderid. total FROM orders WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02' ORDER BY total DESC.SELECT orderid. . (SYSDATE-hire_date)/7 AS WEEKS FROM employees WHERE department_id = 90. total FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' ORDER BY total DESC. 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. Refer to Section 1 15. Incorrect. SELECT last_name. (SYSDATE-hire_date)/7 DISPLAY WEEKS FROM employees WHERE department id = 90. SELECT last_name. (SYSDATE-hire_date)AS WEEK FROM employees WHERE department_id = 90. # of WEEKS FROM employees WHERE department_id = 90.(*) SELECT last name. Refer to Section 1 Section 2 Lesson 1 . (*) . Not all date functions return date values. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 Correct 17.(Answer all questions in this section) 16. Which two statements concerning SQL functions are true? (Choose two. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001.) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. All Human Resources data is stored in a table named EMPLOYEES. 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 . Incorrect. Each employee's salary must be displayed in the following format: $000. 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.000. Refer to Section 2 18.00. You have been asked to create a report that displays each employee's name and salary.Number functions can return number or character values. . 2004 ). Which statement should you issue? Mark for Review (1) Points SELECT companyname. Date Month.6 SYSDATE + 30 / 24 Incorrect. The report's date should be displayed in the Day. Year format (For example. yyyy'). Refer to Section 2 20. TO_CHAR (sysdate. Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . Tuesday. You have been asked to create a report that lists all customers who have placed orders of at least $2. total FROM customers NATURAL JOIN orders WHERE total >= 2500. 13 April. dy month.TO_DATE('01-OCT-2004') (*) NEXT_DAY(hire_date) + 5 SYSDATE .500.19. 'fmdd. dd Month. dy month. yyyy'). TO_DATE (date. Refer to Section 2 Page 2 of 10 . total FROM customers NATURAL JOIN orders WHERE total >= 2500. 'dd. 'day. TO_DATE (sysdate. yyyy'). (*) Incorrect. dd month. TO_CHAR (sysdate. total FROM customers NATURAL JOIN orders WHERE total >= 2500. 'fmDay. SELECT companyname. total FROM customers NATURAL JOIN orders WHERE total >= 2500. SELECT companyname.SELECT companyname. yyyy'). ) 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 date value to character string or number. Section 2 Lesson 1 (Answer all questions in this section) 21. and question scores below. Which three statements concerning explicit data type conversions are true? (Choose three. An asterisk (*) indicates a correct answer. feedback.Test: Mid Term Exam .Database Programming with SQL Review your answers. 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. and COALESCE can be used with group functions to replace null values. NVL and COALESCE. can be used with group functions to replace null values. Refer to Section 2 Section 2 Lesson 2 (Answer all questions in this section) 22. (*) Incorrect. Incorrect. but not COALESCE.Use the TO_CHAR function to convert a number or date value to character string. but not NVL and NVL2. can be used with group functions to replace null values. but not NVL2. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. (*) COALESCE. NVL2. can be used with group functions to replace null values. NVL. Refer to Section 2 . 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. The statement would fail because values cannot be divided by null. You need to replace null values in the DEPARTMENT_ID column with the text "N/A". Which functions should you use? Mark for Review . The PRODUCT table contains this column: PRICE NUMBER(7.2) Evaluate this statement: SELECT NVL(10 / price.23. A value of 0 would be displayed. Correct 24. (*) A value of 10 would be displayed. '0') FROM PRODUCT. Refer to Section 2 Section 3 Lesson 2 (Answer all questions in this section) 25.(1) Points TO_CHAR and NVL (*) TO_CHAR and NULL TO_CHAR and NULLIF TO_NUMBER and NULLIF Incorrect. 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 . 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.2 (*) 3 Incorrect. The company president would like the sales listed starting with the highest amount first.000.2) SALES_DEPT SALES_ID NUMBER(10) PRIMARY KEY SALES NUMBER(20) QUOTA NUMBER(20) MANAGER NUMBER(10) BONUS NUMBER(10) . 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. Refer to Section 3 26. bonus. s.last_name. s.employee_id = s. e.last_name.last_name.employee_id AND s.last_name.employee_id.bonus.first_name. s.EMPLOYEE_ID NUMBER(10) FOREIGN KEY Which SELECT statement will accomplish this task? Mark for Review (1) Points SELECT e.employee_id.bonus.employee_id FROM employees e. s. e. s.sales FROM employees e. sales_dept s WHERE e.employee_id. sales_dept s AND s. e. e. s. SELECT e. SELECT e.bonus. sales_dept s ORDER BY sales DESC WHERE e.employee_id. s.employee_id = s.employee_id = s.bonus IS NOT NULL AND sales > 50000.first_name. sales ORDER BY sales DESC FROM employees e. s. e.employee_id. e.first_name. SELECT e.bonus IS NOT NULL.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC. s. s.employee_id. e.employee_id AND sales > 50000 AND s. s. s.employee_id.first_name.employee_id. e. sales WHERE e. sales . Which clause contains a syntax error? Mark for Review (1) Points SELECT e. d. sales_dept s WHERE e.first_name.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC. d.department_name FROM employees e. Refer to Section 3 27. e. Evaluate this SQL statement: SELECT e.employee_id.department_id > 5000 ORDER BY 4. departments d WHERE e.employee_id = s. departments d .department_id = d. e.department_name FROM employees e.last_name.FROM employees e. e.last_name.department_id AND employees.first_name. (*) Incorrect.employee_id. e.employee_id AND s. 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.department_id = d.WHERE e. doctors. . Refer to Section 3 28.department_id > 5000 (*) ORDER BY 4. doctor_id FROM patients. Incorrect.department_id AND employees. 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 .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. a Cartesian product (*) Incorrect. 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 . 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. AND. Using Oracle Proprietary join syntax. An asterisk (*) indicates a correct answer.Test: Mid Term Exam .. and IN IN and = . and question scores below. feedback.Database Programming with SQL Review your answers.... 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. Section 3 Lesson 4 (Answer all questions in this section) 31. RIGHT. Using Oracle Proprietary join syntax. or LEFT keyword must be included.Correct 32. Refer to Section 3 33. which operator would you use after one of the column names in the WHERE clause when creating an outer join? Mark for Review (1) Points (+) (*) * . The FULL. Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. Incorrect. (*) Outer joins are always evaluated before other types of joins in the query. The OR operator cannot be used to link outer join conditions. datatype and precision.+ = 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. 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 . Refer to Section 4 36. Which of the following conditions will cause an error on a NATURAL JOIN? Mark for Review (1) Points . 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.Correct 35. 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. If it selects rows from the two tables that have equal values in all matched columns.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. 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 . 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. Refer to Section 4 38.The SELECT clause A USING clause (*) Incorrect.2) . Which statement could you use? Mark for Review (1) Points SELECT c.customer_id = s. Primary Key CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table ORDER_DT DATE ORDER_AMT NUMBER (7.customer_name FROM customers c.customer_id FROM sales_order s).SALES_ORDER ORDER_ID NUMBER NOT NULL.customer_name FROM customers c. sales_order s WHERE c. SELECT c. sales_order s . (*) SELECT c.customer_id not in (SELECT s.2) SHIP_METHOD VARCHAR2 (5) You need to create a report that displays customers without a sales order.customer_name FROM customers c WHERE c.customer_id(+). Incorrect. SELECT c.customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c.customer_id.customer_id = s.WHERE c.customer_id). 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.customer_id (+) = s. Refer to Section 4 . Refer to Section 4 39. first_name as "Physician". c.physician_id) (*) JOIN admission c ON (a.patient_id) Incorrect.patient_id = c. b.40.physician_id = c. ' || a. Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b. ' || b. Evaluate this SELECT statement: SELECT a.physician_id = c.physician_id) JOIN admission c ON (a. Refer to Section 4 .admission FROM patient a JOIN physician b ON (b.patient_id).last_name || '.first_name as "Patient".last_name || '.patient_id = c. and question scores below.Page 4 of 10 Test: Mid Term Exam . orderdate. Which query represents the correct syntax for a left outer join? Mark for Review (1) Points SELECT companyname. feedback. An asterisk (*) indicates a correct answer. total FROM customers c LEFT JOIN orders o . Section 4 Lesson 4 (Answer all questions in this section) 41.Database Programming with SQL Review your answers. Incorrect.cust_id. SELECT companyname. Refer to Section 4 . total FROM customers c LEFT OUTER orders o ON c. total FROM customers c OUTER JOIN orders o ON c.ON c.cust_id.cust_id = o.cust_id.cust_id = o. orderdate.cust_id = o. SELECT companyname. (*) SELECT companyname. total FROM customers c LEFT OUTER JOIN orders o ON c.cust_id = o. orderdate. orderdate.cust_id. Refer to Section 4 43. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables.42. Which type of join would you use? Mark for Review (1) Points a right outer join a left outer join a full outer join (*) . 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. an inner join Incorrect. The highest salary in each department. department_id FROM employees GROUP BY department_id. Which values are displayed? Mark for Review (1) Points The highest salary for all employees. (*) . Evaluate this SELECT statement: SELECT MAX(salary). Refer to Section 4 Section 5 Lesson 1 (Answer all questions in this section) 44. The employees with the highest salaries. The employee with the highest salary for each department. Correct 45. The hire dates in the EMPLOYEES table that contain NULL values. . Evaluate this SELECT statement: SELECT MIN(hire_date). The latest hire date in the EMPLOYEES table. (*) The the earliest hire date in the EMPLOYEES table. department_id FROM employees GROUP BY department_id. Which values are displayed? Mark for Review (1) Points The earliest hire date in each department. Group functions can be nested to a depth of? Mark for Review (1) Points three . 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.Incorrect. Refer to Section 5 47. Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP VARIANCE . You need to calculate the standard deviation for the cost of products produced in the Birmingham facility.four two (*) Group functions cannot be nested. Refer to Section 5 Section 5 Lesson 2 (Answer all questions in this section) 48. Incorrect. SELECT AVG(price). Refer to Section 5 49. . SELECT AVG(price) FROM trucks WHERE model IS 4x4. 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'. model FROM trucks WHERE model = '4x4'.Incorrect. (*) SELECT AVG (price) FROM trucks WHERE model IS '4x4'. You need to compute the total salary for all employees in department 10.Correct 50. Which group function will you use? Mark for Review (1) Points MAX SUM (*) VARIANCE COUNT Correct Page 5 of 10 . Database Programming with SQL Review your answers. feedback.Test: Mid Term Exam . Which aggregate function can be used on a column of the DATE data type? Mark for Review (1) Points AVG MAX (*) STDDEV SUM Incorrect. An asterisk (*) indicates a correct answer. Section 5 Lesson 2 (Answer all questions in this section) 51. Refer to Section 5 . and question scores below. 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.52. prod_qty) . 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. The values in the PROD_PRICE column and the PROD_QTY column are averaged together. An error occurs. The AVG. (*) Incorrect.FROM products. Only the average quantity of the products is returned. VARIANCE. and STDDEV functions can be used with which of the following? Mark for Review (1) Points Only numeric data types (*) Integers only . Refer to Section 5 54. SUM. 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. Any data type All except numeric Correct 55.2) CATEGORY VARCHAR2(20) You need to calculate the average credit limit for all the customers in each category. Which group function should you use to calculate this value? Mark for Review (1) Points AVG (*) SUM COUNT . 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. The CUSTOMERS table contains these columns: CUSTOMER_ID NUMBER(9) FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7. Which results will the query display? Mark for Review (1) Points The number of employees that have a salary less than 30000. Evaluate this SELECT statement: SELECT COUNT(*) FROM employees WHERE salary > 30000. Refer to Section 5 Section 5 Lesson 3 (Answer all questions in this section) 56. .STDDEV Incorrect. The total of the SALARY column for all employees that have a salary greater than 30000. SELECT * FROM employees WHERE salary < 50000. (*) The query generates an error and returns no results. 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. Correct 57.The number of rows in the EMPLOYEES table that have a salary greater than 30000. department_id.SELECT COUNT(*) FROM employees WHERE salary < 50000. Evaluate this SQL statement: SELECT COUNT (amount) FROM inventory. salary. (*) SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id. last_name. SELECT COUNT(*) FROM employees WHERE salary > 50000. What will occur when the statement is issued? . Refer to Section 5 58. first_name. Incorrect. The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not null. SELECT COUNT (*) FROM products. (*) Incorrect. 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. 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.Mark for Review (1) Points The statement will return the greatest value in the INVENTORY table. Refer to Section 5 59. manager_id FROM employees GROUP BY department_id. department_id. Refer to Section 5 Section 6 Lesson 1 (Answer all questions in this section) 60. Incorrect. Evaluate this SELECT statement: SELECT SUM(salary). based on a group function? Mark for Review (1) Points HAVING SUM(salary) > 100000 (*) WHERE SUM(salary) > 100000 WHERE salary > 100000 . Which SELECT statement clause allows you to restrict the rows returned. manager_id.SELECT ROWCOUNT FROM products. Section 6 Lesson 1 (Answer all questions in this section) 61.HAVING salary > 100000 Incorrect.Database Programming with SQL Review your answers. An asterisk (*) indicates a correct answer. Which statement about the GROUP BY clause is true? Mark for Review . and question scores below. Refer to Section 6 Page 6 of 10 Test: Mid Term Exam . feedback. You must use the HAVING clause with the GROUP BY clause. 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.(1) Points To exclude rows before dividing them into groups using the GROUP BY clause. Correct 62. 2003 ? Mark for Review (1) Points SELECT customer_id. you should use a WHERE clause. 2003 and June 30. COUNT(payment_id) . (*) You can use a column alias in a GROUP BY clause. By default. rows are not sorted when a GROUP BY clause is used. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'.FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. Incorrect. Refer to Section 6 . (*) SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. SELECT customer_id. SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. Why does this statement return a syntax error? Mark for Review (1) Points MGR_ID must be included in the GROUP BY clause. Refer to Section 6 . Incorrect. A single query cannot contain a WHERE clause and a HAVING clause. Evaluate this SELECT statement: SELECT COUNT(emp_id). dept_id FROM employee WHERE status = 'I' GROUP BY dept_id HAVING salary > 30000 ORDER BY 2.63. (*) The HAVING clause must specify an aggregate function. mgr_id. The ORDER BY clause must specify a column name in the EMPLOYEE table. You only want to include employees who earn more than 15000. department_id FROM employees GROUP BY department_id. Evaluate this SELECT statement: SELECT COUNT(employee_id). Refer to Section 6 65.64. 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. The PLAYERS table contains these columns: PLAYER_ID NUMBER PK PLAYER_NAME VARCHAR2 (30) . ) Mark for Review (1) Points (Choose all correct answers) ORDER BY AVG(salary) (*) GROUP BY MAX(salary) SELECT AVG(NVL(salary.TEAM_ID NUMBER HIRE_DATE DATE SALARY NUMBER (8. Refer to Section 6 66. The EMPLOYEES table contains these columns: . 0)) (*) HAVING MAX(salary) > 10000 (*) WHERE hire_date > AVG(hire_date) Incorrect.2) Which two clauses represent valid uses of aggregate functions? (Choose three. The SALARY column is NOT included in the GROUP BY clause. The HIRE_DATE column is NOT included in the GROUP BY clause. The WHERE clause contains a syntax error. hire_date. (*) .2) HIRE_DATE DATE Evaluate this SQL statement: SELECT id_number. id_number. name ORDER BY hire_date. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing.ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER SALARY NUMBER (7. department_id. name. Refer to Section 6 67. Mark for Review (1) Points (Choose all correct answers) SELECT department_id. AVG(salary) WHERE job_id <> 69879 (*) GROUP BY job_id. Which clauses restricts the result? Choose two. department_id . AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id.Incorrect. Evaluate this statement: SELECT department_id. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. HAVING AVG(salary) > 35000 (*) Correct Section 6 Lesson 2 (Answer all questions in this section) 68. Incorrect. Which statement about subqueries is true? Mark for Review (1) Points Subqueries should be enclosed in double quotation marks. after the main or outer query executes. (*) Subqueries generally execute last. Subqueries cannot contain group functions. Subqueries are often used in a WHERE clause to return values for an unknown conditional value. Refer to Section 6 . Refer to Section 6 70. Which operator can be used with a multiple-row subquery? Mark for Review (1) Points IN (*) <> = LIKE Incorrect.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 . (*) SELECT * FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963). 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 max_capacity > 0).TEACHER_ID NUMBER (5) START_DATE DATE MAX_CAPACITY NUMBER (3) All MAX_CAPACITY values are greater than 10. Refer to Section 6 Page 7 of 10 Test: Mid Term Exam . SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id). Incorrect.SELECT * FROM teachers WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0).Database Programming with SQL . An asterisk (*) indicates a correct answer. feedback.Review your answers. Which SELECT statement should you use? Mark for Review (1) Points . and question scores below. You need to create a report to display the names of products with a cost value greater than the average cost of all products. 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. Section 6 Lesson 2 (Answer all questions in this section) 71. Refer to Section 6 . SELECT AVG(cost). (*) SELECT product_name FROM products WHERE cost > AVG(cost).SELECT product_name FROM products WHERE cost > (SELECT AVG(cost) FROM product). 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. Examine the structure of the EMPLOYEE. Refer to Section 6 74. and ORDERS tables. If a single-row subquery returns a null value and uses the equality comparison operator.Section 6 Lesson 3 (Answer all questions in this section) 73. EMPLOYEE EMPLOYEE_ID NUMBER(9) . DEPARTMENT. 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. Which of the following constructs would you use? Mark for Review (1) Points a group function a single-row subquery (*) the HAVING clause .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. Refer to Section 6 Section 6 Lesson 4 (Answer all questions in this section) . The <> operator can be used when a single-row subquery returns only one row.a MERGE statement Incorrect. The <> operator returns the same result as the ANY operator in a subquery. Refer to Section 6 75. (*) Incorrect. 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. 76. last_name. but less than $50. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). All employees who work in a department with employees who earn more than $30.000.000. (*) Correct . All employees who work in a department with employees who earn more than $30.000.000. Evaluate this SQL statement: SELECT employee_id.000. Only employees who earn less than $50.000 and more than $50. Which values will be displayed? Mark for Review (1) Points Only employees who earn more than $30. but used to be in department 15.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. last_name. new_dept_id . first_name. Which query should you use? Mark for Review (1) Points SELECT employee_id.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. department_id) IN (SELECT employee_id. department_id FROM employee WHERE (employee_id. dept_id . first_name. first_name. department_id FROM employee WHERE (employee_id. department_id) IN (SELECT employee_id. (*) SELECT employee_id. new_dept_id FROM depart_hist WHERE new_dept_id = 15). last_name. SELECT employee_id. SELECT employee_id. department_id FROM employee WHERE (employee_id. last_name. first_name.FROM depart_hist WHERE old_dept_id = 15) AND new_dept_id = 10. department_id FROM employee WHERE (employee_id) IN (SELECT employee_id FROM employee_hist WHERE old_dept_id = 15). last_name. department_id) = (SELECT employee_id. SELECT description FROM d_types WHERE code <> ALL (SELECT type_code FROM d_songs). .FROM employee WHERE old_dept_id = 15). SELECT description FROM d_types WHERE code = ANY (SELECT type_code FROM d_songs). 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). Incorrect. . What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. (*) Incorrect. 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. (*) All the rows in the table would be selected. No rows would be returned by the outer query. Refer to Section 6 79.All of the above.00). (*) Single-row operators can be used with both single-row and multiple-row subqueries. 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. Correct Page 8 of 10 . Refer to Section 6 80. Multiple-row subqueries can only be used in SELECT statements. Incorrect. Multiple-row subqueries can be used with both single-row and multiple-row operators.Only the rows with CUSTOMER_ID values equal to null would be selected. Test: Mid Term Exam . An asterisk (*) indicates a correct answer. and question scores below.Database Programming with SQL Review your answers. 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 . feedback. Section 6 Lesson 4 (Answer all questions in this section) 81. No rows would be returned from the STUDENT table. first_name FROM student WHERE major_id NOT IN (SELECT major_id FROM majors WHERE department_head_id = 30 AND title = 'ADJUNCT').Correct 82. Only the rows with STUDENT_ID values equal to NULL would be displayed. last_name. (*) All the rows in the STUDENT table would be displayed. Evaluate this SELECT statement: SELECT student_id. What would happen if the inner query returned a NULL value row? Mark for Review (1) Points A syntax error would be returned. Correct . (*) Second subquery found on the right instead of the left side of the operator. first_name FROM customer .83. Evaluate this SELECT statement that includes a subquery: SELECT last_name. Incorrect. The greater than operator is not valid. Refer to Section 6 84. 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. Which of the following is a valid reason why the query below will not execute successfully? SELECT employee_id. last_name. Which statement is true about the given subquery? Mark for Review (1) Points The outer query executes before the nested subquery. What is wrong with the following query? SELECT employee_id. The results of the inner query are returned to the outer query. Refer to Section 6 85. last_name FROM employees WHERE salary = (SELECT MIN(salary) FROM employees GROUP BY department_id). . or an error occurs.WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). (*) 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. Incorrect. Incorrect. Refer to Section 6 86.Mark for Review (1) Points Single rows contain multiple values and a logical operator is used. it will run without problems. job_id FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE department_name = 'Executive'). Mark for Review (1) Points . You are looking for Executive information using a subquery. Subquery returns more than one row and single row comparison operator is used. (*) Subquery references the wrong table in the WHERE clause. last_name. Nothing. What will the following SQL statement display? SELECT department_id. 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 . department name and last name for every employee in the Executive department. job ID for every employee in the Executive department. job ID from departments for Executive employees. department name for every Executive in the employees table.The department ID. The department ID. The department ID. last name. (*) Correct Section 7 Lesson 1 (Answer all questions in this section) 87. last name. last name. The department ID. 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. You need to add a row to an existing table. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id. enroll_date FROM students WHERE UPPER(stu_type_id) = 'F'). Incorrect. Refer to Section 7 88. last_name. with an identical structure. who have a STU_TYPE_ID value of "F". named FT_STUDENTS. 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. stu_type_id. first_name.You create another table. Which DML statement should you use? Mark for Review . into the new table. (*) An error occurs because the FT_STUDENTS table already exists.You want to insert all fulltime students. dob. You have been instructed to add a new customer to the CUSTOMERS table. Because the new customer has not had a credit check.(1) Points UPDATE INSERT (*) DELETE CREATE Correct 89. 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 . poc. INSERT INTO customers VALUES (200. (*) INSERT INTO customers VALUES (200. 0. 'samerica'). 'samerica'). 'InterCargo'. samerica). company. 'tflanders'. tflanders. (*) INSERT INTO customers VALUES (cust_id. 'InterCargo'. 'tflanders'. 'InterCargo'. 'samerica'). Incorrect. Refer to Section 7 . poc. InterCargo. 'tflanders'.(Choose all correct answers) INSERT INTO customers (cust_id. location) (200. credit. location) VALUES (200. company. null. 0. location_id) VALUES (70. 100. department_name. Assume all the column names are correct. 'Public Relations'.90. 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 . manager_id. The following SQL statement will execute which of the following? INSERT INTO departments (department_id. 1700). Section 7 Lesson 2 (Answer all questions in this section) 91. has informed you that she was recently married. Janet Roper. Janet is the only person with the last name of Roper that is employed by the company.Test: Mid Term Exam . feedback. An asterisk (*) indicates a correct answer.Database Programming with SQL Review your answers. and she has requested that you update her name in the employee database. Her new last name is Cooper. 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 . One of the sales representatives. and question scores below. UPDATE employees SET cooper = 'last_name' WHERE last_name = 'roper'. UPDATE employees SET last_name = 'roper' WHERE last_name = 'cooper'. (*) UPDATE employees last_name = 'cooper' WHERE last_name = 'roper'.SET last_name = 'cooper' WHERE last_name = 'roper'. Examine the structures of the PLAYERS. and TEAMS tables: PLAYERS . Correct 92. MANAGERS. 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 . CREATE INSERT.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. UPDATE Incorrect. and their team name for all teams with a id value greater than 5000 Incorrect. CREATE MERGE. their manager. Which two commands can be used to create new rows? Mark for Review (1) Points INSERT. You want to enter a new record into the CUSTOMERS table. MERGE (*) INSERT. Refer to Section 7 . Refer to Section 7 93. her last name is now Rockefeller. INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. One of your employees was recently married. Her employee ID is still 189. (*) The statement deletes the CUSTOMER column. (*) Incorrect. however. . 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. Refer to Section 7 95. The statement deletes the first row in the CUSTOMERS table. UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. Evaluate this statement: DELETE FROM customer. UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. Which statement is true? Mark for Review (1) Points The statement deletes all the rows from the CUSTOMER table.94. The statement removes the structure of the CUSTOMER table from the database. 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 96. Refer to Section 7 97. Examine the structures of the PRODUCTS and SUPPLIERS tables: . Incorrect. 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.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. 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. Which script should you use? Mark for Review (1) Points DELETE FROM products WHERE supplier_id IN .SUPPLIERS SUPPLIER_ID NUMBER NOT NULL. DELETE FROM products WHERE supplier_id < (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA').(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA'). DELETE FROM products WHERE supplier_id = (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA'). (*) DELETE FROM products WHERE UPPER(city) = 'ATLANTA'. . what is the result? Mark for Review (1) Points All rows are deleted from the table. The statement will not execute. When the WHERE clause is missing in a DELETE statement. Refer to Section 7 99. (*) The table is removed from the database. Incorrect. 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. Nothing.2) .Correct 98. An error message is displayed indicating incorrect syntax. 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 display the names of the teachers who teach classes that start within the next week. Refer to Section 7 100. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. You need to create a report to display the teachers who were hired more than five years ago. (*) Incorrect. The PLAYERS table contains these columns: PLAYER_ID NUMBER NOT NULL . (*) UPDATE players (salary) VALUES(salary * 1. UPDATE players SET salary = salary * .5 percent.125.125) WHERE team_id = 5960. The TEAM_ID value for the Tiger team is 5960. Refer to Section 7 Page 10 of 10 .125 WHERE team_id = 5960.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. UPDATE players SET salary = salary * 1. Incorrect.125 WHERE team_id = 5960. Which statement should you use? Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1. What will this SELECT statement display? . 'al') FROM dual.31-40!!!! S1L2 1.Midl-mari-lipsesc 10 intrebari. Evaluate this SELECT statement: SELECT LENGTH(email) FROM employee. You issue this SQL statement: SELECT INSTR ('organizational sales'. Which value is returned by this command? 1 2 13 (*) 17 2. The number of characters for each value in the EMAIL column in the employees table. 3. (*) The maximum number of characters allowed in the EMAIL column. The email address of each employee in the EMPLOYEE table.The longest e-mail address in the EMPLOYEE table. Which SQL function can be used to remove heading or trailing characters (or both) from a character string? LPAD CUT NVL2 TRIM (*) . TRUNC. and INITCAP ROUND. and ADD_MONTHS 5. RPAD. Which functions can be used to manipulate character. Which function should you use? LENGTH (*) LPAD COUNT .4. You need to display the number of characters in each customer's last name. and MOD ROUND. TRUNC. number. LOWER. and date column values? CONCAT. and TRIM (*) UPPER. Which character function should you use? INSTR TRUNC . You need to return a portion of each employee's last name. beginning with the first character up to the fifth character.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. Which two functions can be used to manipulate number or date column values.SUBSTR (*) CONCAT 8. 2) Which value is returned? 1 (*) 2 25 0 9.) (Choose all correct answers) . but NOT character column values? (Choose two. Evaluate this function: MOD (25. RPAD TRUNC (*) ROUND (*) INSTR CONCAT 10.248. You issue this SQL statement: SELECT ROUND (1282. -2) FROM dual. What value does this statement produce? 1200 1282 . 25 1300 (*) S1L3 11. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC. Which query should you issue? SELECT orderid. SELECT orderid. You want to create a report that displays all orders and their amounts that were placed during the month of January. total FROM orders WHERE order_date IN ( 01-jan-02 . total FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' . You want the orders with the highest amounts to appear first.1282. 31-jan-02 ) ORDER BY total. SELECT orderid. Which function should you use? ROUND BETWEEN ADD_MONTHS MONTHS_BETWEEN (*) 13. 12. Which of the following Date Functions will add calendar months to a date? . (*) SELECT orderid.ORDER BY total DESC. total FROM orders WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02' ORDER BY total DESC. You need to display the number of months between today's date and each employee's hiredate. 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 . 15. The values returned by this SELECT statement will be of which data type? DATE (*) NUMBER DATETIME INTEGER S2 L1 . 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. All Human Resources data is stored in a table named EMPLOYEES.16.00.000. 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 function should you include in a SELECT statement to achieve the desired result? TO_CHAR (*) TO_DATE TO_NUMBER CHARTOROWID 17.00"? . Each employee's salary must be displayed in the following format: $000.000. Which script should you use to display the salaries in format: "$45. You have been asked to create a report that displays each employee's name and salary. SELECT TO_CHAR(salary.999. SELECT TO_NUM(salary.SELECT TO_CHAR(salary. Single row functions cannot modify a data type.999. '$999. SELECT TO_NUM(salary. Which statement concerning single row functions is true? Single row functions can accept only one argument.990.99') FROM employees.00') FROM employees. Single row functions can be nested. but can return multiple values. '$999. '$999. (*) 18. (*) .999') FROM employees. '$999.00') FROM employees. 19. The TO_CHAR function can be used to display dates and numbers according to formatting conventions that are supported by Oracle. . 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 only be used on DATE columns.Single row functions return one or more results per row. The TO_CHAR function can be used to remove text from column data that will be returned by the database. 20. SUBSTR. TRUNC.If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001. LPAD. TO_NUMBER (*) . ADD_MONTHS LENGTH. TO_DATE. what year would be the result? 2001 1901 2017 (*) 1917 21. Which functions allow you to perform explicit data type conversions? ROUND. TRIM TO_CHAR. NULLIF S2L2 22. 23. 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. SELECT tuition_balance + housing_balance FROM student_accounts. (*) SELECT NVL(tuition_balance. 0). SELECT TO_NUMBER(tuition_balance.NVL. NVL2. 0). 0) "Balance Due" FROM student_accounts. When executed. tutition_balance + housing_balance "Balance Due" FROM student_accounts. TO_NUMBER (housing_balance. NVL (housing_balance). . tuition_balance + housing_balance "Balance Due" FROM student_accounts. 0). A value of 0 would be displayed.2) Evaluate this statement: SELECT NVL(10 / price. What would happen if the PRICE column contains null values? The statement would fail because values cannot be divided by 0. (*) . '0') FROM PRODUCT. The PRODUCT table contains this column: PRICE NUMBER(7.Which of the following General Functions will return the first non-null expression in the expression list? NVL NVL2 NULLIF COALESCE (*) 24. A value of 10 would be displayed. Which query should you issue to accomplish this task? SELECT last_name. SELECT last_name. S3 L2 25. You need to create a report that lists all employees in the Sales department who do not earn $25. . first_name. salary FROM employees WHERE salary = 25000 AND dept_id = 10. salary FROM employees WHERE salary > 25000 AND dept_id = 10. first_name. The statement would fail because values cannot be divided by null.000 per year. SELECT last_name. Which clause contains a syntax error? SELECT e.last_name. first_name.department_id > 5000 ORDER BY 4. d. e. e.department_id = d. (*) 26.first_name.department_name FROM employees e. SELECT last_name. salary FROM employees WHERE salary != 25000 AND dept_id = 10.employee_id.last_name.employee_id. e.first_name. salary FROM employees WHERE salary <= 25000 AND dept_id = 10. first_name. e.department_name FROM employees e.department_id AND employees. departments d . Evaluate this SQL statement: SELECT e. d. departments d WHERE e. department_id > 5000 (*) ORDER BY 4.department_id AND employees. 27. What is produced when a join condition is not specified in a multiple-table query? .WHERE e. 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.department_id = d. exhausting all possibilities The table is joined to another equal table All rows that do not match in the WHERE clause are displayed 28. one column to the next column. a self-join an outer join an equijoin a Cartesian product (*) 29. doctor_id FROM patients. Which result will this statement provide? . 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. doctors. 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.emp_id AND revenue >= 100000. (*) . SELECT e. e.fname.lname.000 in revenue. sales s WHERE e. e.emp_id AND revenue > 100000. s. sales s WHERE e.emp_id = s.fname.lname.emp_id = s.sales FROM employees e. s. Which query should you issue? SELECT e.sales FROM employees e. Your have two tables named EMPLOYEES and SALES. You want to identify the sales representatives who have generated at least $100. What should be included in a SELECT statement to return NULL values from all tables? o o o o natural joins left outer joins full outer joins (*) right outer joins . SELECT fname.emp_id AND revenue > 100000. sales Q FROM employees e.emp_id = s. sales s WHERE e. You need to display all the rows from both the EMPLOYEE and EMPLOYEE_HIST tables.emp_id AND revenue >= 100000.lname. 31-40????? S 4 L4 41. Which type of join would you use? o o o o a right outer join a left outer join a full outer join (*) an inner join 42.SELECT e. e.sales FROM employees. lname. s. sales WHERE e.fname.emp_id = s. 43. Evaluate this SELECT statement: SELECT MIN(hire_date). dept_id FROM employee GROUP BY dept_id. Which type of join will you use? o o o o a cross join an inner join a left outer join a right outer join (*) S 5 L1 44. You need to join the EMPLOYEE_HIST and EMPLOYEE tables. Which statement about the GROUP BY clause is true? o o o o 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. 45. (*) . Which values are displayed? o The earliest hire date in each department. 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. The GROUP BY clause can contain an aggregate function. A GROUP BY clause cannot be used without an ORDER BY clause. o o o The the earliest hire date in the EMPLOYEE table. 47. Group functions can be nested to a depth of o o o o three four two (*) Group functions cannot be nested. S 5 L2 48. COUNT(*) FROM employees GROUP BY job_id. (*) Displays only the number of job_ids. The hire dates in the EMPLOYEE table that contain NULL values. o o o o Displays all the employees and groups them by job. What will the following SQL Statement do? SELECT job_id. Displays all the jobs with as many people as there are jobs. Displays each job id and the number of people assigned to that job id. The latest hire date in the EMPLOYEE table. Which group function would you use to display the total of all salary values in the EMPLOYEE table? o o o SUM (*) AVG COUNT . 46. Examine the data in the PAYMENT table: PAYMENT_ID 86590586 89453485 85490345 CUSTOMER_ID PAYMENT_DATE 8908090 8549038 5489304 10-JUN-03 15-FEB-03 20-MAR-03 PAYMENT_TYPE PAYMENT_AMOUNT BASIC 859. Which SELECT statement should you use? o SELECT AVG(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003'.00 596. February and March of 2003. Which group function would you use to display the lowest value in the SALES_AMOUNT column? o o o o AVG COUNT MAX MIN (*) 50. 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) .o MAX 49.00 You need to determine the average payment amount made by each customer in January.00 INTEREST BASIC 568. 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'.FROM payment WHERE TO_CHAR(payment_date) IN (JAN. SELECT AVG(price). . FEB. 52. model FROM trucks WHERE model IS '4x4'. SELECT AVG(price) FROM trucks WHERE model IS 4x4. (*) SELECT AVG (price) FROM trucks WHERE model IS '4x4'. MAR). Which group function should you use to calculate this value? AVG (*) SUM COUNT STDDEV 53. 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.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 EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) . 2) HIRE_DATE DATE BONUS NUMBER(7.2) COMM_PCT NUMBER(4. or SALARY columns? (Choose three.) (Choose all correct answers) MAX (*) SUM AVG MIN (*) COUNT (*) 54. LAST_NAME.2) Which three functions could be used with the HIRE_DATE.FIRST_NAME VARCHAR2(20) SALARY NUMBER(9. Which group function would you use to display the highest salary value in the EMPLOYEE table? . Which group function would you use to display the average price of all products in the PRODUCTS table? SUM AVG (*) COUNT .AVG COUNT MAX (*) MIN 55. 57.60 PRODUCT_ID 0. Which SELECT statement will calculate the number of rows in the PRODUCTS table? SELECT COUNT(products).05 PRICE DISCOUNT .MAX S5L3 56. (*) SELECT ROWCOUNT FROM products.99 768385 862459 849869 5. SELECT COUNT (*) FROM products. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID 890898 847589 848399 8. SELECT COUNT FROM products.10 0. 50 You query the LINE_ITEM table and a value of 5 is returned.60 954039 439203 438925 5. What will occur when the statement is issued? The statement will return the greatest value in the INVENTORY table.867950 985490 945809 5. SELECT AVG(discount) FROM line_item. Evaluate this SQL statement: SELECT COUNT (amount) FROM inventory. . Which SQL statement did you execute? 0. SELECT COUNT(*) FROM line_item.25 543949 349302 453235 4. (*) SELECT SUM(discount) FROM line_item. 58.15 SELECT COUNT(discount) FROM line_item. The statement will return the total number of rows in the AMOUNT column. (*) The COUNT function can be used to find the maximum value in each column. . The statement will replace all NULL values that exist in the AMOUNT column. The COUNT function always ignores null values by default. The COUNT function can be used to determine the number of unique. (*) 59. Which statement about the COUNT function is true? The COUNT function ignores duplicates by default. The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not null. non-null values in a column. 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 . Evaluate this SELECT statement: SELECT SUM(salary). dept_id. Which clause of the SELECT statement contains a syntax error? .SELECT FROM WHERE GROUP BY HAVING ORDER BY (*) SELECT FROM WHERE HAVING ORDER BY GROUP BY 61. department_name FROM employee WHERE dept_id = 1 GROUP BY department. Which SELECT statement clause allows you to restrict the rows returned.SELECT FROM WHERE GROUP BY (*) 62. dept_id. Evaluate this SELECT statement: SELECT SUM(salary). based on a group function? HAVING SUM(salary) > 100000 (*) WHERE SUM(salary) > 100000 WHERE salary > 100000 . mgr_id FROM employee GROUP BY dept_id. mgr_id. dept_id FROM employee WHERE status = 'I' GROUP BY dept_id HAVING salary > 30000 ORDER BY 2. A single query cannot contain a WHERE clause and a HAVING clause. (*) The HAVING clause must specify an aggregate function.HAVING salary > 100000 63. . Evaluate this SELECT statement: SELECT COUNT(emp_id). The ORDER BY clause must specify a column name in the EMPLOYEE table. mgr_id. Why does this statement return a syntax error? MGR_ID must be included in the GROUP BY clause. prod_cat. 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. MIN (prod_price) FROM products GROUP BY prod_price. (*) SELECT MIN (prod_price). prod_cat FROM products GROUP BY MIN (prod_price). MIN (prod_price) FROM products GROUP BY prod_cat. SELECT prod_cat.64. . Which statement could you use to accomplish this task? SELECT prod_cat. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. AVG(salary) WHERE job_id <> 69879 (*) GROUP BY job_id. MIN (prod_cat) FROM products GROUP BY prod_cat. 65.SELECT prod_price. department_id . Evaluate this statement: SELECT department_id. (Choose all correct answers) SELECT department_id. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. Which clauses restricts the result? Choose two. 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. You want to write a report that returns the average salary of all employees in the company.HAVING AVG(salary) > 35000 (*) 66. sorted by departments. (*) SELECT AVG (salary) FROM employees . Which statement about the GROUP BY clause is true? To exclude rows before dividing them into groups using the GROUP BY clause. SELECT AVG salary FROM employees BY dept. rows are not sorted when a GROUP BY clause is used. You must use the HAVING clause with the GROUP BY clause.BY dept. S6L2 . By default. (*) You can use a column alias in a GROUP BY clause. 67. you use should a WHERE clause. 68. (*) 69. Using a subquery in which clause will return a syntax error? WHERE FROM HAVING There are no places you cannot place subqueries. Which operator can be used with subqueries that return only one row? LIKE (*) . 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 . 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. Examine the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8. You need to display each date that a customer placed an order.2) OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8.71. (*) . 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. Which operator can be used with a multiple-row subquery? IN (*) <> = LIKE S6 L3 73. and ORDERS tables. DEPARTMENT. EMPLOYEE EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) DEPARTMENT DEPARTMENT_ID NUMBER(9) .72. Examine the structure of the EMPLOYEE. 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 . You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. . 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. Which query should you issue to accomplish this task? SELECT * FROM employees WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). However.74. you are not sure which supervisor ID belongs to Brad Carter. SELECT * FROM employees WHERE supervisor_id = (SELECT employee_id FROM employees WHERE last_name = 'Carter'). (*) . SELECT * FROM supervisors WHERE supervisor_id = (SELECT employee_id FROM supervisors WHERE last_name = 'Carter').SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). department name and last name for every employee in the Executive department. . You are looking for Executive information using a subquery.S6 L4 76. job_id FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE department_name = 'Executive'). What will the following SQL statement display? SELECT department_id. The department ID. last_name. 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. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). last name. last name. The department ID. job ID for every employee in the Executive department.000. .000 and more than $50. department name for every Executive in the employees table.000. Which values will be displayed? Only employees who earn more than $30. last_name. last name. Evaluate this SQL statement: SELECT employee_id. All employees who work in a department with employees who earn more than $30. (*) 78. job ID from departments for Executive employees. The department ID.000. Only employees who earn less than $50.The department ID. 00 This statement fails when executed: SELECT customer_id.000. (*) 79.00 OR payment_date = '20-MAR-2003'). Examine the data in the PAYMENT table: PAYMENT_ID 86590586 89453485 85490345 CUSTOMER_ID PAYMENT_DATE 8908090 8549038 5489304 10-JUN-03 15-FEB-03 20-MAR-03 PAYMENT_TYPE PAYMENT_AMOUNT BASIC 859. but less than $50. Which change could correct the problem? Change the outer query WHERE clause to 'WHERE payment_id IN'. . payment_type FROM payment WHERE payment_id = (SELECT payment_id FROM payment WHERE payment_amount = 596.000. Remove the parentheses surrounding the nested SELECT statement.All employees who work in a department with employees who earn more than $30.00 596.00 INTEREST BASIC 568. (*) Remove the quotes surrounding the date value in the OR clause. Refer to Section 6 80. Which of the following best describes the meaning of the ANY operator? . Incorrect. Which operator or keyword cannot be used with a multiple-row subquery? ALL ANY = (*) > 81.Change the comparison operator to a single-row 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. (*) Single-row operators can be used with both single-row and multiple-row subqueries. Which statement about single-row and multiple-row subqueries is true? Multiple-row subqueries cannot be used with the LIKE operator. Refer to Section 6 82. . name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500.00). No rows would be returned by the outer query. Evaluate this SELECT statement: SELECT customer_id. Multiple-row subqueries can only be used in SELECT statements. . (*) All the rows in the table would be selected. What would happen if the inner query returned null? An error would be returned.Multiple-row subqueries can be used with both single-row and multiple-row operators. 83. last_name. . No rows would be returned from the STUDENT table. Incorrect.Only the rows with CUSTOMER_ID values equal to null would be selected. Refer to Section 6 84. What would happen if the inner query returned a NULL value row? A syntax error would be returned. Evaluate this SELECT statement: SELECT student_id. first_name FROM student WHERE major_id NOT IN (SELECT major_id FROM majors WHERE department_head_id = 30 AND title = 'ADJUNCT'). (*) All the rows in the STUDENT table would be displayed. AND. which comparison operator(s) can you use? IN.. Incorrect... and ALL (*) LIKE BETWEEN. Evaluate this SELECT statement that includes a subquery: SELECT last_name. <. Refer to Section 6 85.. You need to create a SELECT statement that contains a multiple-row subquery.Only the rows with STUDENT_ID values equal to NULL would be displayed. =. first_name FROM customer . ANY. and > 86. 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 . (*) An error occurs if the either the inner or outer queries do not return a value. The results of the inner query are returned to the outer query. S7L1 87. Both the inner and outer queries must return a value. or an error occurs.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. and assuming that a column can accept null values. named FT_STUDENTS. An error occurs because you CANNOT use a subquery in an INSERT statement. Using the INSERT statement. stu_type_id. (*) An error occurs because the FT_STUDENTS table already exists. how can you implicitly insert a null value in a column? Use the NULL keyword. dob. What is the result of executing this INSERT statement? All full-time students are inserted into the FT_STUDENTS table. who have a STU_TYPE_ID value of "F".ENROLL_DATE DATE You create another table. with an identical structure. 88.You want to insert all fulltime students. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id. An error occurs because the INSERT statement does NOT contain a VALUES clause. enroll_date FROM students WHERE UPPER(stu_type_id) = 'F'). first_name. into the new table. . last_name. 8690. (*) INSERT INTO products VALUES (2958. .09. 8690. 700). (*) It is not possible to implicitly insert a null value in a column.Use the ON clause Omit the column in the column list.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. 4.04.2) COST NUMBER (5. 4. 'Cable'. SYSDATE). 7. The PRODUCTS table contains these columns: PRODUCT_ID NUMBER NOT NULL PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER NOT NULL LIST_PRICE NUMBER (7.04. 'Cable'. 7. 89.09. 'Cable'). Incorrect. Which DML statement should you use? UPDATE INSERT (*) DELETE CREATE . SYSDATE). supplier_id VALUES (2958.INSERT INTO products(product_id. product_name. 'Cable'. Refer to Section 7 90. INSERT INTO products(product_id. You need to add a row to an existing table. 8690. product_name) VALUES (2958. and TEAMS tables: PLAYERS PLAYER_ID NUMBER Primary Key LAST_NAME VARCHAR2 (30) FIRST_NAME VARCHAR2 (25) . Examine the structures of the PLAYERS. MANAGERS. 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. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table using one UPDATE statement.S7L2 91. 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 (*) .2) SALARY NUMBER(9.TEAM_ID NUMBER MGR_ID NUMBER SIGNING_BONUS NUMBER(9. and she has requested that you update her name in the employee database. The EMPLOYEES table contains these columns and all data is stored in lowercase: EMP_ID NUMBER(10) PRIMARY KEY . their manager. 94. Refer to Section 7 93. and their team name for all teams with a id value greater than 5000 Incorrect. Janet Roper. No rows would be deleted. Janet is the only person with the last name of Roper that is employed by the company. Her new last name is Cooper. What would happen if you issued a DELETE statement without a WHERE clause? All the rows in the table would be deleted. Only one row would be deleted.To display each player. (*) An error message would be returned. has informed you that she was recently married. One of the sales representatives. UPDATE employees SET cooper = 'lname' WHERE lname = 'roper'.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 SET lname = 'roper' WHERE lname = 'cooper'. (*) UPDATE employees lname = 'cooper' WHERE lname = 'roper'. When the WHERE clause is missing in a DELETE statement. Nothing. . Which statement should you use? UPDATE players (salary) SET salary = salary * 1. 96. An error message is displayed indicating incorrect syntax.2) You need to increase the salary of each player for all players on the Tiger team by 12. (*) The table is removed from the database.5 percent. The statement will not execute. what is the result? All rows are deleted from the table.125. The TEAM_ID value for the Tiger team is 5960. 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.95. 125 WHERE team_id = 5960.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? . UPDATE players SET salary = salary * 1. (*) UPDATE players (salary) VALUES(salary * 1. 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.125) WHERE team_id = 5960.125 WHERE team_id = 5960.UPDATE players SET salary = salary * . Which statement is true? The statement deletes all the rows from the CUSTOMER table. (*) 98. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. You need to display the names of the teachers who teach classes that start within the next week.You need to display the start date for each class taught by a given teacher. Evaluate this statement: DELETE FROM customer. You need to create a report to display the teachers who were hired more than five years ago. The statement deletes the first row in the CUSTOMERS table. (*) The statement deletes the CUSTOMER column. The statement removes the structure of the CUSTOMER table from the database. . 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. CREATE MERGE. Which two commands can be used to create new rows? INSERT. CREATE INSERT.99. MERGE (*) . You need to update the expiration date of products manufactured before June 30th . You want to enter a new record into the CUSTOMERS table. INSERT. 4))) "Default Password" . Section 1 Lesson 1 (Answer all questions in this section) 1. UPDATE Test: Mid Term Exam .Database Programming with SQL Review your answers. (SUBSTR(LOWER(first_name). An asterisk (*) indicates a correct answer. feedback. You query the database with this SQL statement: SELECT CONCAT(last_name. and question scores below. Correct 2. Which function will be evaluated first? Mark for Review (1) Points CONCAT SUBSTR LOWER (*) All three will be evaluated simultaneously.FROM employees. Which character function should you use? Mark for Review (1) Points INSTR TRUNC . You need to return a portion of each employee's last name. beginning with the first character up to the fifth character. The email address of each employee in the EMPLOYEES table. (*) . Evaluate this SELECT statement: SELECT LENGTH(email) FROM employees. The number of characters for each value in the EMAIL column in the EMPLOYEES table. What will this SELECT statement display? Mark for Review (1) Points The longest e-mail address in the EMPLOYEES table.SUBSTR (*) CONCAT Correct 3. leftpadded with the $ and the column labeled SALARY. The last name and salary for all employees with the format of the salary 15 characters long. The last name and the format of the salary limited to 15 digits to the left of the decimal and the column labeled SALARY. size of 15 and the column labeled SALARY. '$')SALARY FROM employees. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value." . (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected.The maximum number of characters allowed in the EMAIL column. What will the following SQL statement display? SELECT last_name. Correct 4. 15. LPAD(salary. CONCAT. SUBSTR SUBSTR. In which order are the functions evaluated? Mark for Review (1) Points LOWER. LOWER (*) Correct .Incorrect. CONCAT. Refer to Section 1 5. SUBSTR. LOWER CONCAT. first_name)). CONCAT LOWER. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. 5) "ID" FROM employee. 1. SUBSTR. 00 968950 SANDAL 85909 10. 2.6. . -2.2) FROM styles WHERE style_id = 895840.00 758960 SANDAL 86979 12.00 869506 SANDAL 89690 15. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 857689 HEEL 85940 11.00 890890 LOAFER 89789 14.00 You query the database and return the value 79. SELECT INSTR(category.2) FROM styles WHERE style_id = 895840.00 809090 LOAFER 89098 10. Which script did you use? Mark for Review (1) Points SELECT INSTR(category. SELECT SUBSTR(category.2) FROM styles WHERE style_id = 758960. 2. -2. Which function should you use? Mark for Review (1) Points CASE UCASE UPPER (*) .SELECT SUBSTR(category. (*) Correct 7. You need to display each employee's name in all uppercase letters.2) FROM styles WHERE style_id = 895840. Which comparison operator retrieves a list of values? Mark for Review (1) Points IN (*) LIKE BETWEEN. Refer to Section 1 Lesson 1 ...IN.TOUPPER Correct Section 1 Lesson 2 (Answer all questions in this section) 8. IS NULL Incorrect... -1) FROM dual. Which value does this statement display? Mark for Review (1) Points 700 750 (*) 751 751. Evaluate this function: MOD (25.9. You issue this SQL statement: SELECT TRUNC(751. 2) Which value is returned? Mark for Review (1) Points .367.3 Correct 10. 1 (*) 2 25 0 Correct Page 1 of 10 Test: Mid Term Exam .Database Programming with SQL Review your answers. An asterisk (*) indicates a correct answer. feedback. and question scores below. Section 1 Lesson 3 . 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) .(Answer all questions in this section) 11. Evaluate this SELECT statement: SELECT hire_date + eval_months FROM employees. Refer to Section 1 13. Which function should you use? Mark for Review (1) Points . The values returned by this SELECT statement will be of which data type? Mark for Review (1) Points DATE (*) NUMBER DATETIME INTEGER Incorrect. You need to subtract three months from the current date. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC.ROUND TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN Incorrect. You want to create a report that displays all orders and their amounts that were placed during the month of January. Refer to Section 1 14. 31-jan-02 ) . Which query should you issue? Mark for Review (1) Points SELECT orderid. You want the orders with the highest amounts to appear first. total FROM orders WHERE order_date IN ( 01-jan-02 . SELECT orderid. (SYSDATE-hire_date)/7 AS WEEKS FROM employees . Incorrect. total FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' ORDER BY total DESC. Refer to Section 1 15. SELECT orderid. (*) SELECT orderid.ORDER BY total. total FROM orders WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02' ORDER BY total DESC. 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. Refer to Section 1 . (SYSDATE-hire_date)/7 DISPLAY WEEKS FROM employees WHERE department id = 90. (SYSDATE-hire_date)AS WEEK FROM employees WHERE department_id = 90. (*) SELECT last name. SELECT last_name. SELECT last_name. Incorrect.WHERE department_id = 90. # of WEEKS FROM employees WHERE department_id = 90. what year would be the result? Mark for Review (1) Points 2001 1901 2017 (*) 1917 Correct 17. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001. Which two statements concerning SQL functions are true? (Choose two.Section 2 Lesson 1 (Answer all questions in this section) 16.) Mark for Review (1) Points (Choose all correct answers) Character functions can accept numeric input. . 00.000. (*) Number functions can return number or character values. (*) Single-row functions manipulate groups of rows to return one result per group of rows. Each employee's salary must be displayed in the following format: $000. 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. 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. Conversion functions convert a value from one data type to another data type.Not all date functions return date values. Refer to Section 2 18. 6 SYSDATE + 30 / 24 Incorrect. dy month. The report's date should be displayed in the Day. total FROM customers NATURAL JOIN orders WHERE total >= 2500.500. You have been asked to create a report that lists all customers who have placed orders of at least $2. Which statement should you issue? Mark for Review (1) Points SELECT companyname. Date Month. Which arithmetic operation will return a numeric value? Mark for Review (1) Points TO_DATE('01-JUN-2004') . 'fmdd. Year format (For example.TO_DATE('01-OCT-2004') (*) NEXT_DAY(hire_date) + 5 SYSDATE . Tuesday. 2004 ).Incorrect. yyyy'). TO_CHAR (sysdate. Refer to Section 2 19. . 13 April. Refer to Section 2 20. (*) Incorrect. 'day. dy month. TO_DATE (date. 'fmDay. yyyy'). total FROM customers NATURAL JOIN orders WHERE total >= 2500. TO_CHAR (sysdate. dd month. 'dd. Refer to Section 2 Page 2 of 10 . total FROM customers NATURAL JOIN orders WHERE total >= 2500. SELECT companyname. dd Month.SELECT companyname. TO_DATE (sysdate. yyyy'). SELECT companyname. total FROM customers NATURAL JOIN orders WHERE total >= 2500. yyyy'). (*) . Section 2 Lesson 1 (Answer all questions in this section) 21. and question scores below. feedback. Which three statements concerning explicit data type conversions are true? (Choose three. (*) Use the TO_NUMBER function to convert a character string of digits to a number. Use the TO_DATE function to convert a character string to a date value. An asterisk (*) indicates a correct answer.) Mark for Review (1) Points (Choose all correct answers) Use the TO_NUMBER function to convert a number to a character string.Database Programming with SQL Review your answers.Test: Mid Term Exam . but not COALESCE.Use the TO_DATE function to convert a date value to character string or number. NVL and COALESCE. (*) COALESCE. but not NVL2. Which statement about group functions is true? Mark for Review (1) Points NVL and NVL2. and COALESCE can be used with group functions to replace null values. can be used with group functions to replace null values. . Use the TO_CHAR function to convert a number or date value to character string. but not NVL and NVL2. Refer to Section 2 Section 2 Lesson 2 (Answer all questions in this section) 22. NVL. can be used with group functions to replace null values. (*) Incorrect. can be used with group functions to replace null values. NVL2. (*) A value of 10 would be displayed.Incorrect. The statement would fail because values cannot be divided by null. A value of 0 would be displayed. Refer to Section 2 23. The PRODUCT table contains this column: PRICE NUMBER(7. 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. '0') FROM PRODUCT.2) Evaluate this statement: SELECT NVL(10 / price. Correct . Refer to Section 2 Section 3 Lesson 2 (Answer all questions in this section) 25. When joining 3 tables in a SELECT statement. You need to replace null values in the DEPARTMENT_ID column with the text "N/A". how many join conditions are needed in the WHERE clause? Mark for Review (1) Points 0 .24. 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. 2) SALES_DEPT SALES_ID NUMBER(10) PRIMARY KEY SALES NUMBER(20) QUOTA NUMBER(20) . 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. The company president would like the sales listed starting with the highest amount first. Refer to Section 3 26.1 2 (*) 3 Incorrect.000. 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. e.bonus IS NOT NULL.first_name. . sales WHERE e. s.last_name. s.bonus.bonus.employee_id = s. e. s.employee_id.first_name. sales ORDER BY sales DESC FROM employees e.employee_id.employee_id = s.bonus.employee_id FROM employees e.employee_id AND sales > 50000 AND s.sales FROM employees e. sales_dept s ORDER BY sales DESC WHERE e.employee_id = s.bonus IS NOT NULL AND sales > 50000.employee_id. s. s.employee_id AND s.employee_id. s. sales_dept s AND s. e. e. sales_dept s WHERE e.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. s.first_name.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC. SELECT e. e.last_name.last_name.employee_id. s.employee_id. SELECT e. s. e. department_name FROM employees e. e.employee_id.first_name.department_id > 5000 ORDER BY 4. s.employee_id.last_name. Evaluate this SQL statement: SELECT e.department_id = d.employee_id.SELECT e.last_name. e. s. Which clause contains a syntax error? Mark for Review (1) Points SELECT e.employee_id AND s.first_name. d.employee_id. Refer to Section 3 27.department_name . e. d. sales_dept s WHERE e. e. departments d WHERE e. e.department_id AND employees. (*) Incorrect.last_name. sales FROM employees e.bonus IS NOT NULL AND sales > 50000 ORDER BY sales DESC. s.employee_id = s.first_name.bonus. e. FROM employees e. 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.department_id AND employees. departments d WHERE e. doctor_id . Incorrect.department_id = d. Refer to Section 3 28.department_id > 5000 (*) ORDER BY 4. 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 . 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.FROM patients. doctors. 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 .an equijoin a Cartesian product (*) Incorrect. 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. Refer to Section 3 30. one column to the next column. ..AND. Using Oracle Proprietary join syntax. and IN IN and = . An asterisk (*) indicates a correct answer. 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 question scores below.Database Programming with SQL Review your answers.. feedback.Test: Mid Term Exam . Section 3 Lesson 4 (Answer all questions in this section) 31. RIGHT. The OR operator cannot be used to link outer join conditions. The FULL. Refer to Section 3 33. Using Oracle Proprietary join syntax. Incorrect.Correct 32. or LEFT keyword must be included. (*) Outer joins are always evaluated before other types of joins in the query. 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 (+) (*) . Which statement about outer joins is true? Mark for Review (1) Points The tables must be aliased. You need to join two tables that have two columns with the same name. 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 Section 4 Lesson 2 (Answer all questions in this section) 34. datatype and precision. 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 .Correct 35. 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. If the columns having the same names have different data types. If it selects rows from the two tables that have equal values in all matched columns. When the NATURAL JOIN clause is based on all columns in the two tables that have the same name. (*) 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 .36. then an error is returned. The FROM clause The SELECT clause A USING clause (*) Incorrect. Refer to Section 4 38. 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) . Below find the structure of the CUSTOMERS and SALES_ORDER tables: CUSTOMERS CUSTOMER_ID NUMBER NOT NULL. SALES_ORDER ORDER_ID NUMBER NOT NULL.customer_name FROM customers c. Which statement could you use? Mark for Review (1) Points SELECT c. sales_order s WHERE c.2) SHIP_METHOD VARCHAR2 (5) You need to create a report that displays customers without a sales order. (*) SELECT c.customer_id(+). Primary Key CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table ORDER_DT DATE ORDER_AMT NUMBER (7.customer_id FROM sales_order s).customer_id not in (SELECT s.customer_name FROM customers c WHERE c.customer_id = s. . customer_id = s. sales_order s WHERE c. Incorrect.SELECT c. Refer to Section 4 39.customer_name FROM customers c.customer_id.customer_name FROM customers c RIGHT OUTER JOIN sales_order s ON (c. 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 . SELECT c.customer_id (+) = s.customer_id). Incorrect.patient_id) .first_name as "Physician".physician_id) (*) JOIN admission c ON (a.physician_id = c. Refer to Section 4 40. b.patient_id = c.physician_id) JOIN admission c ON (a.first_name as "Patient".patient_id = c. Evaluate this SELECT statement: SELECT a. ' || a.admission FROM patient a JOIN physician b ON (b. Which clause generates an error? Mark for Review (1) Points JOIN physician b ON (b. c.last_name || '.last_name || '. ' || b.physician_id = c.patient_id). 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. and question scores below.Incorrect. feedback. total . An asterisk (*) indicates a correct answer.Database Programming with SQL Review your answers. Refer to Section 4 Page 4 of 10 Test: Mid Term Exam . cust_id. total FROM customers c LEFT OUTER orders o ON c.cust_id = o. orderdate. SELECT companyname.FROM customers c LEFT JOIN orders o ON c.cust_id = o. total FROM customers c OUTER JOIN orders o ON c. SELECT companyname. . orderdate. (*) SELECT companyname.cust_id = o.cust_id = o.cust_id. orderdate.cust_id.cust_id. total FROM customers c LEFT OUTER JOIN orders o ON c. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HISTS tables. Refer to Section 4 43. 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.Incorrect. Refer to Section 4 42. Which type of join would you use? Mark for Review (1) Points a right outer join a left outer join . Refer to Section 4 Section 5 Lesson 1 (Answer all questions in this section) 44. .a full outer join (*) an inner join Incorrect. Which values are displayed? Mark for Review (1) Points The highest salary for all employees. department_id FROM employees GROUP BY department_id. Evaluate this SELECT statement: SELECT MAX(salary). The highest salary in each department. The latest hire date in the EMPLOYEES table. The employee with the highest salary for each department. Evaluate this SELECT statement: SELECT MIN(hire_date). (*) The employees with the highest salaries. Which values are displayed? Mark for Review (1) Points The earliest hire date in each department. department_id FROM employees GROUP BY department_id. Correct 45. . (*) The the earliest hire date in the EMPLOYEES table. Refer to Section 5 47.The hire dates in the EMPLOYEES table that contain NULL values. Refer to Section 5 46. Group functions can be nested to a depth of? Mark for Review (1) Points . Incorrect. 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. Incorrect.three four two (*) Group functions cannot be nested. Which group function will you use? Mark for Review (1) Points STDEV STDDEV (*) VAR_SAMP . 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. model FROM trucks WHERE model = '4x4'. SELECT AVG(price) FROM trucks WHERE model IS 4x4. (*) SELECT AVG (price) FROM trucks WHERE model IS '4x4'. 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). .VARIANCE Incorrect. Which group function will you use? Mark for Review (1) Points MAX SUM (*) VARIANCE COUNT Correct Page 5 of 10 .Correct 50. You need to compute the total salary for all employees in department 10. Which aggregate function can be used on a column of the DATE data type? Mark for Review (1) Points AVG MAX (*) STDDEV SUM Incorrect. and question scores below. An asterisk (*) indicates a correct answer.Database Programming with SQL Review your answers. feedback. Section 5 Lesson 2 (Answer all questions in this section) 51.Test: Mid Term Exam . Refer to Section 5 . 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: .52. 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. An error occurs. Refer to Section 5 54.SELECT AVG(prod_price. The values in the PROD_PRICE column and the PROD_QTY column are averaged together. and STDDEV functions can be used with which of the following? Mark for Review (1) Points Only numeric data types (*) . prod_qty) FROM products. VARIANCE. The AVG. SUM. Only the average quantity of the products is returned. (*) Incorrect. The CUSTOMERS table contains these columns: CUSTOMER_ID NUMBER(9) FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7.Integers only Any data type All except numeric Correct 55.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 . Evaluate this SELECT statement: SELECT COUNT(*) FROM employees WHERE salary > 30000. Refer to Section 5 Section 5 Lesson 3 (Answer all questions in this section) 56. .COUNT STDDEV Incorrect. Which results will the query display? Mark for Review (1) Points The number of employees that have a salary less than 30000. The number of rows in the EMPLOYEES table that have a salary greater than 30000. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7. Correct 57. .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.The total of the SALARY column for all employees that have a salary greater than 30000. (*) The query generates an error and returns no results. SELECT * FROM employees WHERE salary < 50000. salary. department_id. Evaluate this SQL statement: SELECT COUNT (amount) FROM inventory. SELECT COUNT(*) FROM employees WHERE salary < 50000. . Refer to Section 5 58. Incorrect. SELECT COUNT(*) FROM employees WHERE salary > 50000. last_name. (*) SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id. first_name. The statement will replace all NULL values that exist in the AMOUNT column. (*) Incorrect. Refer to Section 5 59. The statement will return the total number of rows in the AMOUNT column.What will occur when the statement is issued? Mark for Review (1) Points The statement will return the greatest value in the INVENTORY table. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for Review (1) Points SELECT COUNT(products). . The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not null. SELECT COUNT FROM products. Refer to Section 5 Section 6 Lesson 1 (Answer all questions in this section) 60. Incorrect.SELECT COUNT (*) FROM products. Evaluate this SELECT statement: SELECT SUM(salary). manager_id. (*) SELECT ROWCOUNT FROM products. based on a group function? Mark for Review (1) Points HAVING SUM(salary) > 100000 (*) WHERE SUM(salary) > 100000 . Which SELECT statement clause allows you to restrict the rows returned. manager_id FROM employees GROUP BY department_id. department_id. Refer to Section 6 Page 6 of 10 Test: Mid Term Exam . feedback.Database Programming with SQL Review your answers. and question scores below. Section 6 Lesson 1 (Answer all questions in this section) . An asterisk (*) indicates a correct answer.WHERE salary > 100000 HAVING salary > 100000 Incorrect. You must use the HAVING clause with the GROUP BY clause. Correct 62.61. 2003 ? Mark for Review (1) Points . (*) You can use a column alias in a GROUP BY clause. 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. 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. rows are not sorted when a GROUP BY clause is used. you should use a WHERE clause. By default. SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'.SELECT customer_id. SELECT customer_id. (*) SELECT COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'. . COUNT(payment_id) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003' GROUP BY customer_id. Incorrect. Evaluate this SELECT statement: SELECT COUNT(emp_id). Refer to Section 6 63.Incorrect. The ORDER BY clause must specify a column name in the EMPLOYEE table. (*) The HAVING clause must specify an aggregate function. dept_id FROM employee WHERE status = 'I' GROUP BY dept_id HAVING salary > 30000 ORDER BY 2. Refer to Section 6 . mgr_id. A single query cannot contain a WHERE clause and a HAVING clause. Why does this statement return a syntax error? Mark for Review (1) Points MGR_ID must be included in the GROUP BY clause. 64. department_id FROM employees GROUP BY department_id. Refer to Section 6 65. Evaluate this SELECT statement: SELECT COUNT(employee_id). The PLAYERS table contains these columns: . 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 .) 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.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. Why will this statement cause an error? Mark for Review (1) Points The HAVING clause is missing.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. SUM(salary) FROM employees WHERE salary > 25000 GROUP BY department_id. . name ORDER BY hire_date. hire_date. name. department_id. id_number. The WHERE clause contains a syntax error. The SALARY column is NOT included in the GROUP BY clause. Mark for Review (1) Points (Choose all correct answers) SELECT department_id. AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. (*) Incorrect. Refer to Section 6 67. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. Evaluate this statement: SELECT department_id. AVG(salary) WHERE job_id <> 69879 (*) .The HIRE_DATE column is NOT included in the GROUP BY clause. Which clauses restricts the result? Choose two. after the main or outer query executes. department_id HAVING AVG(salary) > 35000 (*) Correct Section 6 Lesson 2 (Answer all questions in this section) 68. . Subqueries are often used in a WHERE clause to return values for an unknown conditional value. Which statement about subqueries is true? Mark for Review (1) Points Subqueries should be enclosed in double quotation marks.GROUP BY job_id. Subqueries cannot contain group functions. (*) Subqueries generally execute last. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns: TEACHERS TEACHER_ID NUMBER(5) Primary Key NAME VARCHAR2 (25) SUBJECT_ID NUMBER(5) .Incorrect. Which operator can be used with a multiple-row subquery? Mark for Review (1) Points IN (*) <> = LIKE Incorrect. Refer to Section 6 69. Refer to Section 6 70. 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.) 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). Which two SQL statements correctly use subqueries? (Choose two. (*) SELECT * . FROM teachers WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0). Refer to Section 6 Page 7 of 10 . SELECT * FROM teachers WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0). Incorrect. SELECT * FROM class_assignments WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id). (*) Correct .Database Programming with SQL Review your answers. and question scores below. 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. An asterisk (*) indicates a correct answer. Section 6 Lesson 2 (Answer all questions in this section) 71.Test: Mid Term Exam . feedback. You need to create a report to display the names of products with a cost value greater than the average cost of all products.72. SELECT product_name FROM (SELECT AVG(cost) FROM product) WHERE cost > AVG(cost). 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). . product_name FROM products WHERE cost > AVG(cost) GROUP by product_name. SELECT AVG(cost). Examine the structure of the EMPLOYEE.Incorrect. DEPARTMENT. and ORDERS tables. . 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. If a single-row subquery returns a null value and uses the equality comparison operator. Refer to Section 6 Section 6 Lesson 3 (Answer all questions in this section) 73. Which of the following constructs would you use? Mark for Review (1) Points a group function a single-row subquery (*) .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 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. Refer to Section 6 . (*) Incorrect. The <> operator returns the same result as the ANY operator in a subquery. Refer to Section 6 75.the HAVING clause a MERGE statement Incorrect. The <> operator can be used when a single-row subquery returns only one row. but less than $50. Evaluate this SQL statement: SELECT employee_id. All employees who work in a department with employees who earn more than $30. last_name. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000).000.000.000.Section 6 Lesson 4 (Answer all questions in this section) 76.000 and more than $50. 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. first_name.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.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. Which query should you use? Mark for Review (1) Points SELECT employee_id. department_id FROM employee . last_name. but used to be in department 15. new_dept_id FROM depart_hist WHERE old_dept_id = 15) AND new_dept_id = 10. last_name. last_name. first_name. last_name. department_id FROM employee WHERE (employee_id.WHERE (employee_id. department_id FROM employee . department_id) = (SELECT employee_id. first_name. department_id) IN (SELECT employee_id. SELECT employee_id. department_id FROM employee WHERE (employee_id) IN (SELECT employee_id FROM employee_hist WHERE old_dept_id = 15). new_dept_id FROM depart_hist WHERE new_dept_id = 15). (*) SELECT employee_id. SELECT employee_id. first_name. SELECT description FROM d_types . dept_id FROM employee WHERE old_dept_id = 15). Refer to Section 6 78. Incorrect.WHERE (employee_id. 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). department_id) IN (SELECT employee_id. No rows would be returned by the outer query. (*) .WHERE code <> ALL (SELECT type_code FROM d_songs). All of the above. name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. Evaluate this SELECT statement: SELECT customer_id. What would happen if the inner query returned null? Mark for Review (1) Points An error would be returned. Refer to Section 6 79.00). (*) Incorrect. 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. Correct Page 8 of 10 .All the rows in the table would be selected. Incorrect. Multiple-row subqueries can be used with both single-row and multiple-row operators. Refer to Section 6 80. Multiple-row subqueries can only be used in SELECT statements. Only the rows with CUSTOMER_ID values equal to null would be selected. Database Programming with SQL Review your answers. and question scores below.Test: Mid Term Exam . feedback. Section 6 Lesson 4 (Answer all questions in this section) 81. An asterisk (*) indicates a correct answer. 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 . first_name FROM student WHERE major_id NOT IN (SELECT major_id FROM majors WHERE department_head_id = 30 AND title = 'ADJUNCT'). Only the rows with STUDENT_ID values equal to NULL would be displayed. . (*) All the rows in the STUDENT table would be displayed.Correct 82. No rows would be returned from the STUDENT table. last_name. Evaluate this SELECT statement: SELECT student_id. What would happen if the inner query returned a NULL value row? Mark for Review (1) Points A syntax error would be returned. last_name. Which of the following is a valid reason why the query below will not execute successfully? SELECT employee_id. Evaluate this SELECT statement that includes a subquery: . (*) Second subquery found on the right instead of the left side of the operator. Refer to Section 6 84. The greater than operator is not valid. 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.Correct 83. Incorrect. What is wrong with the following query? SELECT employee_id. last_name FROM employees WHERE salary = . 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. Refer to Section 6 85.SELECT last_name. Which statement is true about the given subquery? Mark for Review (1) Points The outer query executes before the nested subquery. Incorrect. first_name FROM customer WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). or an error occurs. Both the inner and outer queries must return a value. last_name. Subquery returns more than one row and single row comparison operator is used.(SELECT MIN(salary) FROM employees GROUP BY department_id). job_id FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE department_name = 'Executive'). (*) Subquery references the wrong table in the WHERE clause. Mark for Review (1) Points Single rows contain multiple values and a logical operator is used. Nothing. Incorrect. Refer to Section 6 86. What will the following SQL statement display? SELECT department_id. Mark for Review . You are looking for Executive information using a subquery. it will run without problems. The department ID. The department ID. 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 . department name for every Executive in the employees table. job ID for every employee in the Executive department. department name and last name for every employee in the Executive department. job ID from departments for Executive employees. last name. The department ID. last name.(1) Points The department ID. (*) Correct Section 7 Lesson 1 (Answer all questions in this section) 87. last name. who have a STU_TYPE_ID value of "F". An error occurs because you CANNOT use a subquery in an INSERT statement. into the new table. last_name. enroll_date FROM students WHERE UPPER(stu_type_id) = 'F'). (*) An error occurs because the FT_STUDENTS table already exists. first_name. An error occurs because the INSERT statement does NOT contain a VALUES clause. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id. Refer to Section 7 . 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. Incorrect. stu_type_id. named FT_STUDENTS. dob. with an identical structure.You want to insert all fulltime students.ENROLL_DATE DATE You create another table. The CUSTOMERS table contains these columns: CUST_ID NUMBER(10) COMPANY VARCHAR2(30) CREDIT NUMBER(10) POC VARCHAR2(30) LOCATION VARCHAR2(30) . you should not add an amount to the CREDIT column. Which DML statement should you use? Mark for Review (1) Points UPDATE INSERT (*) DELETE CREATE Correct 89. You need to add a row to an existing table.88. Because the new customer has not had a credit check. You have been instructed to add a new customer to the CUSTOMERS table. 'InterCargo'. 'InterCargo'. 'tflanders'. 'samerica'). company. (*) INSERT INTO customers VALUES (200. 'tflanders'. location) (200. 0. 'samerica'). location) VALUES (200.Which two INSERT statements will accomplish your objective? Mark for Review (1) Points (Choose all correct answers) INSERT INTO customers (cust_id. 'InterCargo'. 'samerica'). INSERT INTO customers VALUES (200. credit. poc. null. poc. (*) INSERT INTO customers VALUES (cust_id. samerica). InterCargo. company. tflanders. . 0. 'tflanders'. Incorrect. Assume all the column names are correct. 'Public Relations'. location_id) VALUES (70. manager_id. Refer to Section 7 90. The following SQL statement will execute which of the following? INSERT INTO departments (department_id. 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 . department_name. Janet Roper. Section 7 Lesson 2 (Answer all questions in this section) 91. and she has requested that you update her name in the employee database.Database Programming with SQL Review your answers. feedback. One of the sales representatives. An asterisk (*) indicates a correct answer. Janet is the only person with the last name of Roper that is employed by the company. Her new last name is Cooper. and question scores below. has informed you that she was recently married.Test: Mid Term Exam . 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 . Correct . (*) UPDATE employees last_name = 'cooper' WHERE last_name = 'roper'. UPDATE employees SET cooper = 'last_name' WHERE last_name = 'roper'. UPDATE employees SET last_name = 'roper' WHERE last_name = 'cooper'.(1) Points UPDATE employees SET last_name = 'cooper' WHERE last_name = 'roper'. 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.92.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 . Examine the structures of the PLAYERS. MANAGERS. CREATE MERGE. CREATE INSERT. MERGE (*) INSERT. You want to enter a new record into the CUSTOMERS table. UPDATE . and their team name for all teams with a id value greater than 5000 Incorrect.(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. Which two commands can be used to create new rows? Mark for Review (1) Points INSERT. Refer to Section 7 93. Evaluate this statement: DELETE FROM customer. Refer to Section 7 94. (*) Incorrect. Which statement is true? Mark for Review (1) Points The statement deletes all the rows from the CUSTOMER table. One of your employees was recently married.Incorrect. her last name is now Rockefeller. however. INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. 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. Her employee ID is still 189. Refer to Section 7 95. (*) . UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189. Incorrect. 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 96. Refer to Section 7 . The statement removes the structure of the CUSTOMER table from the database. The statement deletes the first row in the CUSTOMERS table.The statement deletes the CUSTOMER column. 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 .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. 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) = 'ATLANTA'). DELETE FROM products WHERE supplier_id < (SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA'). (*) DELETE FROM products WHERE UPPER(city) = 'ATLANTA'. . The statement will not execute. 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. When the WHERE clause is missing in a DELETE statement. Incorrect. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns: TEACHERS TEACHER_ID NUMBER(5) NAME VARCHAR2(25) .Correct 98. Refer to Section 7 99. SUBJECT_ID NUMBER(5) HIRE_DATE DATE SALARY NUMBER(9. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. You need to display the names of the teachers who teach classes that start within the next week. (*) Incorrect. You need to create a report to display the teachers who were hired more than five years ago.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. Refer to Section 7 . 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. Incorrect.2) You need to increase the salary of each player for all players on the Tiger team by 12.125 WHERE team_id = 5960. UPDATE players SET salary = salary * .125 WHERE team_id = 5960. The TEAM_ID value for the Tiger team is 5960.5 percent. Which statement should you use? Mark for Review (1) Points UPDATE players (salary) SET salary = salary * 1. Refer to Section 7 .125) WHERE team_id = 5960.100. UPDATE players SET salary = salary * 1.125. (*) UPDATE players (salary) VALUES(salary * 1. Page 10 of 10 Midl-mari-lipsesc 10 intrebari. 'al') FROM dual. Evaluate this SELECT statement: SELECT LENGTH(email) . You issue this SQL statement: SELECT INSTR ('organizational sales'. Which value is returned by this command? 1 2 13 (*) 17 2.31-40!!!! S1L2 1. (*) The maximum number of characters allowed in the EMAIL column. The number of characters for each value in the EMAIL column in the employees table.FROM employee. Which SQL function can be used to remove heading or trailing characters (or both) from a character string? LPAD CUT NVL2 . The email address of each employee in the EMPLOYEE table. 3. What will this SELECT statement display? The longest e-mail address in the EMPLOYEE table. and INITCAP ROUND. number. Which functions can be used to manipulate character. TRUNC. RPAD. and date column values? CONCAT. TRUNC. LOWER. You need to display the number of characters in each customer's last name. Which function should you use? LENGTH (*) LPAD . and TRIM (*) UPPER.TRIM (*) 4. and ADD_MONTHS 5. and MOD ROUND. Which character function should you use? INSTR . You need to return a portion of each employee's last name. 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. beginning with the first character up to the fifth character.COUNT SUBSTR 6. TRUNC SUBSTR (*) CONCAT 8. 2) Which value is returned? 1 (*) 2 25 0 9. Evaluate this function: MOD (25. . -2) FROM dual.248. You issue this SQL statement: SELECT ROUND (1282.) (Choose all correct answers) RPAD TRUNC (*) ROUND (*) INSTR CONCAT 10. but NOT character column values? (Choose two.Which two functions can be used to manipulate number or date column values. What value does this statement produce? 1200 . . You want to create a report that displays all orders and their amounts that were placed during the month of January. SELECT orderid. 31-jan-02 ) ORDER BY total. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC.25 1300 (*) S1L3 11. Which query should you issue? SELECT orderid. total FROM orders WHERE order_date IN ( 01-jan-02 .1282 1282. You want the orders with the highest amounts to appear first. You need to display the number of months between today's date and each employee's hiredate. 12.SELECT orderid. Which function should you use? ROUND BETWEEN ADD_MONTHS MONTHS_BETWEEN (*) . 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. Which of the following Date Functions will add calendar months to a date? Months + Calendar (Month) ADD_MONTHS (*) MONTHS + Date NEXT_MONTH 14.13. Which function would you use to return the current database server date and time? DATE SYSDATE (*) DATETIME . 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 . The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2 (25) FIRST_NAME VARCHAR2 (25) SALARY NUMBER(6) .S2 L1 16.000. Which function should you include in a SELECT statement to achieve the desired result? TO_CHAR (*) TO_DATE TO_NUMBER CHARTOROWID 17. All Human Resources data is stored in a table named EMPLOYEES. Each employee's salary must be displayed in the following format: $000. You have been asked to create a report that displays each employee's name and salary.00. '$999.00') FROM employees. '$999. '$999.00') FROM employees.000. . SELECT TO_NUM(salary. but can return multiple values.999') FROM employees.00"? SELECT TO_CHAR(salary. Which statement concerning single row functions is true? Single row functions can accept only one argument. '$999. (*) 18.990. SELECT TO_CHAR(salary. Which script should you use to display the salaries in format: "$45.999.999. Single row functions cannot modify a data type.You need to create a report to display the salaries of all employees.99') FROM employees. SELECT TO_NUM(salary. Single row functions can be nested. 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 only be used on DATE columns. . The TO_CHAR function can be used to remove text from column data that will be returned by the database. 19. The TO_CHAR function can be used to display dates and numbers according to formatting conventions that are supported by Oracle. (*) Single row functions return one or more results per row. TRIM TO_CHAR. TRUNC. what year would be the result? 2001 1901 2017 (*) 1917 21. LPAD. ADD_MONTHS LENGTH. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001. TO_NUMBER (*) .20. TO_DATE. SUBSTR. Which functions allow you to perform explicit data type conversions? ROUND. NVL2. 0). 0) "Balance Due" FROM student_accounts. 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.NVL. (*) SELECT NVL(tuition_balance. NULLIF S2L2 22. tuition_balance + housing_balance "Balance Due" FROM student_accounts. NVL (housing_balance). When executed. . SELECT tuition_balance + housing_balance FROM student_accounts. tutition_balance + housing_balance "Balance Due" FROM student_accounts. SELECT TO_NUMBER(tuition_balance. TO_NUMBER (housing_balance. 0). 0). 2) Evaluate this statement: SELECT NVL(10 / price. A value of 0 would be displayed. What would happen if the PRICE column contains null values? The statement would fail because values cannot be divided by 0. The PRODUCT table contains this column: PRICE NUMBER(7. (*) . Which of the following General Functions will return the first non-null expression in the expression list? NVL NVL2 NULLIF COALESCE (*) 24.23. '0') FROM PRODUCT. salary FROM employees . SELECT last_name. first_name. salary FROM employees WHERE salary > 25000 AND dept_id = 10. first_name.000 per year. S3 L2 25.A value of 10 would be displayed. The statement would fail because values cannot be divided by null. You need to create a report that lists all employees in the Sales department who do not earn $25. Which query should you issue to accomplish this task? SELECT last_name. department_id AND employees. first_name. Which clause contains a syntax error? SELECT e. SELECT last_name.department_name FROM employees e.last_name. first_name. e. d.employee_id. d.department_id > 5000 ORDER BY 4.first_name.WHERE salary = 25000 AND dept_id = 10. SELECT last_name. Evaluate this SQL statement: SELECT e.employee_id. salary FROM employees WHERE salary != 25000 AND dept_id = 10. (*) 26. departments d .department_name FROM employees e.first_name.last_name. e. e. e. departments d WHERE e.department_id = d. salary FROM employees WHERE salary <= 25000 AND dept_id = 10. 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.department_id AND employees.WHERE e. What is produced when a join condition is not specified in a multiple-table query? . one column to the next column.department_id = d. exhausting all possibilities The table is joined to another equal table All rows that do not match in the WHERE clause are displayed 28.department_id > 5000 (*) ORDER BY 4. 27. 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.a self-join an outer join an equijoin a Cartesian product (*) 29. doctors. fname.fname.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.emp_id = s. s.lname.emp_id AND revenue > 100000.000 in revenue. e. Your have two tables named EMPLOYEES and SALES. sales s WHERE e.sales FROM employees e.lname.emp_id AND revenue >= 100000. SELECT e. e.emp_id = s. sales s WHERE e. You want to identify the sales representatives who have generated at least $100. Which query should you issue? SELECT e. .sales FROM employees e. s. (*) SELECT e.emp_id = s. sales Q FROM employees e. Which type of join would you use? o o o o a right outer join a left outer join a full outer join (*) an inner join 42.emp_id AND revenue > 100000. You need to display all the rows from both the EMPLOYEE and EMPLOYEE_HIST tables. sales WHERE e. s.fname. 31-40????? S 4 L4 41.emp_id AND revenue >= 100000. SELECT fname.emp_id = s. What should be included in a SELECT statement to return NULL values from all tables? o o o natural joins left outer joins full outer joins (*) . e.sales FROM employees.lname. lname. sales s WHERE e. 45. You need to join the EMPLOYEE_HIST and EMPLOYEE tables. Which statement about the GROUP BY clause is true? o o o o The first column listed in the GROUP BY clause is the most major grouping.o right outer joins 43. dept_id FROM employee GROUP BY dept_id. A GROUP BY clause cannot be used without an ORDER BY clause. All the matched and unmatched rows in the EMPLOYEE table need to be displayed. Which type of join will you use? o o o o a cross join an inner join a left outer join a right outer join (*) S 5 L1 44. Evaluate this SELECT statement: SELECT MIN(hire_date). The GROUP BY clause can contain an aggregate function. Which values are displayed? . (*) The last column listed in the GROUP BY clause is the most major grouping. The EMPLOYEE_HIST table will be the first table in the FROM clause. Group functions can be nested to a depth of o o o o three four two (*) Group functions cannot be nested. (*) The the earliest hire date in the EMPLOYEE table. Which group function would you use to display the total of all salary values in the EMPLOYEE table? o o SUM (*) AVG . S 5 L2 48. Displays each job id and the number of people assigned to that job id. COUNT(*) FROM employees GROUP BY job_id.o o o o The earliest hire date in each department. Displays all the jobs with as many people as there are jobs. The hire dates in the EMPLOYEE table that contain NULL values. 47. What will the following SQL Statement do? SELECT job_id. o o o o Displays all the employees and groups them by job. (*) Displays only the number of job_ids. The latest hire date in the EMPLOYEE table. 46. 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'.00 INTEREST BASIC 568.00 596.00 You need to determine the average payment amount made by each customer in January. Examine the data in the PAYMENT table: PAYMENT_ID 86590586 89453485 85490345 CUSTOMER_ID PAYMENT_DATE 8908090 8549038 5489304 10-JUN-03 15-FEB-03 20-MAR-03 PAYMENT_TYPE PAYMENT_AMOUNT BASIC 859. o SELECT SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003'. Which group function would you use to display the lowest value in the SALES_AMOUNT column? o o o o AVG COUNT MAX MIN (*) 50. o SELECT AVG(payment_amount) (*) FROM payment.o o COUNT MAX 49. FEB.o SELECT AVG(payment_amount) FROM payment WHERE TO_CHAR(payment_date) IN (JAN. (*) SELECT AVG (price) FROM trucks WHERE model IS '4x4'. . 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'. MAR). SELECT AVG(price). SELECT AVG(price) FROM trucks WHERE model IS 4x4. model FROM trucks WHERE model IS '4x4'. S5 L2 51. Which group function should you use to calculate this value? AVG (*) SUM COUNT STDDEV 53. 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. The CUSTOMER table contains these columns: CUSTOMER_ID NUMBER(9) FNAME VARCHAR2(25) LNAME VARCHAR2(30) CREDIT_LIMIT NUMBER (7. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) .52.2) CATEGORY VARCHAR2(20) You need to calculate the average credit limit for all the customers in each category. 2) COMM_PCT NUMBER(4. Which group function would you use to display the highest salary value in the EMPLOYEE table? .) (Choose all correct answers) MAX (*) SUM AVG MIN (*) COUNT (*) 54. LAST_NAME.2) Which three functions could be used with the HIRE_DATE.LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(9. or SALARY columns? (Choose three.2) HIRE_DATE DATE BONUS NUMBER(7. 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 . MAX S5L3 56. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID 890898 847589 848399 8. (*) SELECT ROWCOUNT FROM products.99 PRODUCT_ID 0. SELECT COUNT (*) FROM products. SELECT COUNT FROM products.10 PRICE DISCOUNT . 57. Which SELECT statement will calculate the number of rows in the PRODUCTS table? SELECT COUNT(products). 50 0. What will occur when the statement is issued? The statement will return the greatest value in the INVENTORY table.25 543949 349302 453235 4.60 867950 985490 945809 5. SELECT AVG(discount) FROM line_item.768385 862459 849869 5. Evaluate this SQL statement: SELECT COUNT (amount) FROM inventory. . 58.15 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.05 0. (*) SELECT SUM(discount) FROM line_item.60 954039 439203 438925 5. SELECT COUNT(*) FROM line_item. non-null values in a column.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. . (*) 59. The COUNT function can be used to determine the number of unique. The COUNT function always ignores null values by default. (*) The COUNT function can be used to find the maximum value in each column. The statement will count the number of rows in the INVENTORY table where the AMOUNT column is not null. Which statement about the COUNT function is true? The COUNT function ignores duplicates by default. 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 .S6L1 60. Which clause of the SELECT statement contains a syntax error? . Evaluate this SELECT statement: SELECT SUM(salary).SELECT FROM WHERE GROUP BY HAVING ORDER BY (*) SELECT FROM WHERE HAVING ORDER BY GROUP BY 61. department_name FROM employee WHERE dept_id = 1 GROUP BY department. dept_id. based on a group function? HAVING SUM(salary) > 100000 (*) WHERE SUM(salary) > 100000 . Evaluate this SELECT statement: SELECT SUM(salary). mgr_id FROM employee GROUP BY dept_id.SELECT FROM WHERE GROUP BY (*) 62. dept_id. mgr_id. Which SELECT statement clause allows you to restrict the rows returned. .WHERE salary > 100000 HAVING salary > 100000 63. The ORDER BY clause must specify a column name in the EMPLOYEE table. A single query cannot contain a WHERE clause and a HAVING clause. (*) The HAVING clause must specify an aggregate function. 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. prod_cat FROM products GROUP BY MIN (prod_price).64. . Which statement could you use to accomplish this task? SELECT prod_cat. MIN (prod_price) FROM products GROUP BY prod_cat. 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. SELECT prod_cat. prod_cat. MIN (prod_price) FROM products GROUP BY prod_price. (*) SELECT MIN (prod_price). AVG(salary) FROM employees WHERE job_id <> 69879 GROUP BY job_id. Evaluate this statement: SELECT department_id. department_id . Which clauses restricts the result? Choose two. MIN (prod_cat) FROM products GROUP BY prod_cat. (Choose all correct answers) SELECT department_id. AVG(salary) WHERE job_id <> 69879 (*) GROUP BY job_id. department_id HAVING AVG(salary) > 35000 ORDER BY department_id. 65.SELECT prod_price. HAVING AVG(salary) > 35000 (*) 66. You want to write a report that returns the average salary of all employees in the company. SELECT AVG (salary) FROM employees GROUP BY dept. 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) . sorted by departments. S6L2 . By default. You must use the HAVING clause with the GROUP BY clause. you use should a WHERE clause.FROM employees BY dept. rows are not sorted when a GROUP BY clause is used. Which statement about the GROUP BY clause is true? To exclude rows before dividing them into groups using the GROUP BY clause. 67. (*) You can use a column alias in a GROUP BY clause. SELECT AVG salary FROM employees BY dept. 68. Using a subquery in which clause will return a syntax error? WHERE FROM HAVING There are no places you cannot place subqueries. Which operator can be used with subqueries that return only one row? LIKE (*) . (*) 69. 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 .ANY ALL IN 70. (*) . You need to display all the orders that were placed on the same day as order number 25950. You need to display all the orders that were placed on a certain date. Examine the structures of the CUSTOMER and ORDER_HISTORY tables: CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8. You need to display each date that a customer placed an order.71.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.2) OPEN_DATE DATE ORDER_HISTORY ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8. Which operator can be used with a multiple-row subquery? IN (*) <> = LIKE S6 L3 73. Examine the structure of the EMPLOYEE. DEPARTMENT. EMPLOYEE EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) DEPARTMENT . and ORDERS tables.72. Which of the following constructs would you use? a group function a single-row subquery (*) the HAVING clause a MERGE statement .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. You need to produce a report that contains all employee-related information for those employees who have Brad Carter as a supervisor. 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. Refer to Section 6 74.Incorrect. 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'). 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'). SELECT * FROM supervisors WHERE supervisor_id = (SELECT supervisor_id FROM employees WHERE last_name = 'Carter'). 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. department name and last name for every employee in the Executive department. last_name. job_id FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE department_name = 'Executive'). . What will the following SQL statement display? SELECT department_id.S6 L4 76. The department ID. The department ID. last name.000.000. Evaluate this SQL statement: SELECT employee_id. The department ID. Which values will be displayed? Only employees who earn more than $30. last name. last_name. Only employees who earn less than $50. The department ID. department name for every Executive in the employees table. job ID from departments for Executive employees. . (*) 78. last name. salary FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE salary > 30000 AND salary < 50000). job ID for every employee in the Executive department. 000 and more than $50. but less than $50.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. . All employees who work in a department with employees who earn more than $30. (*) Remove the quotes surrounding the date value in the OR clause.000.000. (*) 79.000. Which change could correct the problem? Change the outer query WHERE clause to 'WHERE payment_id IN'.00 OR payment_date = '20-MAR-2003').00 596.00 INTEREST BASIC 568. Examine the data in the PAYMENT table: PAYMENT_ID 86590586 89453485 85490345 CUSTOMER_ID PAYMENT_DATE 8908090 8549038 5489304 10-JUN-03 15-FEB-03 20-MAR-03 PAYMENT_TYPE PAYMENT_AMOUNT BASIC 859.All employees who work in a department with employees who earn more than $30. Refer to Section 6 80. Change the comparison operator to a single-row operator. Which operator or keyword cannot be used with a multiple-row subquery? ALL ANY = (*) > 81.Remove the parentheses surrounding the nested SELECT statement. . 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.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. name FROM customer WHERE customer_id IN (SELECT customer_id FROM customer WHERE state_id = 'GA' AND credit_limit > 500. 83.00). Multiple-row subqueries can be used with both single-row and multiple-row operators. What would happen if the inner query returned null? An error would be returned. Multiple-row subqueries can only be used in SELECT statements. Evaluate this SELECT statement: SELECT customer_id.Single-row operators can be used with both single-row and multiple-row subqueries. . No rows would be returned by the outer query. (*) All the rows in the table would be selected. No rows would be returned from the STUDENT table. Incorrect. What would happen if the inner query returned a NULL value row? A syntax error would be returned. Evaluate this SELECT statement: SELECT student_id.Only the rows with CUSTOMER_ID values equal to null would be selected. last_name. Refer to Section 6 84. first_name FROM student WHERE major_id NOT IN (SELECT major_id FROM majors WHERE department_head_id = 30 AND title = 'ADJUNCT'). (*) . All the rows in the STUDENT table would be displayed.AND... ANY.. <.. Evaluate this SELECT statement that includes a subquery: . Only the rows with STUDENT_ID values equal to NULL would be displayed. Incorrect. and ALL (*) LIKE BETWEEN. which comparison operator(s) can you use? IN. You need to create a SELECT statement that contains a multiple-row subquery. Refer to Section 6 85. =. and > 86. SELECT last_name. (*) An error occurs if the either the inner or outer queries do not return a value. or an error occurs. S7L1 87. Which statement is true about the given subquery? The outer query executes before the nested subquery. The STUDENTS table contains these columns: STU_ID NUMBER(9) NOT NULL LAST_NAME VARCHAR2 (30) NOT NULL FIRST_NAME VARCHAR2 (25) NOT NULL . The results of the inner query are returned to the outer query. first_name FROM customer WHERE area_code IN (SELECT area_code FROM sales WHERE salesperson_id = 20). Both the inner and outer queries must return a value. You want to insert all fulltime students. (*) An error occurs because the FT_STUDENTS table already exists. first_name. last_name. You execute this INSERT statement: INSERT INTO ft_students (SELECT stu_id. and assuming that a column can accept null values. An error occurs because you CANNOT use a subquery in an INSERT statement. What is the result of executing this INSERT statement? All full-time students are inserted into the FT_STUDENTS table. who have a STU_TYPE_ID value of "F". enroll_date FROM students WHERE UPPER(stu_type_id) = 'F').DOB DATE STU_TYPE_ID VARCHAR2(1) NOT NULL ENROLL_DATE DATE You create another table. dob. An error occurs because the INSERT statement does NOT contain a VALUES clause. stu_type_id. named FT_STUDENTS. Using the INSERT statement. with an identical structure. 88. into the new table. how can you implicitly insert a null value in a column? . 700). 8690.04.2) COST NUMBER (5.09. (*) It is not possible to implicitly insert a null value in a column.Use the NULL keyword. (*) . 7. 'Cable'. Use the ON clause Omit the column in the column list.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. 4. 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. SYSDATE). 7. 'Cable'). 'Cable'. product_name. Incorrect. Refer to Section 7 90. Which DML statement should you use? UPDATE INSERT (*) DELETE .09. SYSDATE). You need to add a row to an existing table. product_name) VALUES (2958. supplier_id VALUES (2958. 4. 8690. 8690. INSERT INTO products(product_id.04.INSERT INTO products VALUES (2958. INSERT INTO products(product_id. 'Cable'. 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. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEE table using one UPDATE statement.CREATE S7L2 91. and TEAMS tables: PLAYERS PLAYER_ID NUMBER Primary Key . MANAGERS. Examine the structures of the PLAYERS. 2) SALARY NUMBER(9.LAST_NAME VARCHAR2 (30) FIRST_NAME VARCHAR2 (25) TEAM_ID NUMBER MGR_ID NUMBER SIGNING_BONUS 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 (*) . their manager. (*) An error message would be returned. What would happen if you issued a DELETE statement without a WHERE clause? All the rows in the table would be deleted. and she has requested that you update her name in the employee database.To display each player. No rows would be deleted. and their team name for all teams with a id value greater than 5000 Incorrect. Janet Roper. Janet . Only one row would be deleted. Refer to Section 7 93. has informed you that she was recently married. 94. Her new last name is Cooper. One of the sales representatives. 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 .is the only person with the last name of Roper that is employed by the company. (*) UPDATE employees lname = 'cooper' WHERE lname = 'roper'. UPDATE employees SET lname = 'roper' WHERE lname = 'cooper'. Nothing.5 percent. (*) The table is removed from the database. When the WHERE clause is missing in a DELETE statement. The statement will not execute. 96. The TEAM_ID value for the Tiger team is 5960. Which statement should you use? . An error message is displayed indicating incorrect syntax.2) You need to increase the salary of each player for all players on the Tiger team by 12. 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.SET cooper = 'lname' WHERE lname = 'roper'. what is the result? All rows are deleted from the table. 95. UPDATE players SET salary = salary * 1.125) WHERE team_id = 5960. (*) UPDATE players (salary) VALUES(salary * 1. 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. 97. UPDATE players SET salary = salary * .125 WHERE team_id = 5960.125 WHERE team_id = 5960.UPDATE players (salary) SET salary = salary * 1.125.2) CLASS_ASSIGNMENTS CLASS_ID NUMBER(5) TEACHER_ID NUMBER(5) START_DATE DATE MAX_CAPACITY NUMBER(3) . The statement deletes the first row in the CUSTOMERS table. You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. . 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 were hired more than five years ago. (*) 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.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. 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. Which two commands can be used to create new rows? INSERT. CREATE .The statement removes the structure of the CUSTOMER table from the database. 99. CREATE MERGE. You need to update the expiration date of products manufactured before June 30th . You want to enter a new record into the CUSTOMERS table. 6. Case and Character Manipulation (Answer all questions in this section) 1.INSERT. feedback. Identify the output from the following SQL statement: SELECT RPAD('SQL'. An asterisk (*) indicates a correct answer. UPDATE Test: Quiz: Case and Character Manipulation Review your answers. and question scores below. '*') FROM DUAL Mark for Review (1) Points ******SQL ***SQL SQL*** (*) . MERGE (*) INSERT. (*) Incorrect. 'Years').SQL****** Correct 2. Refer to Section 1 3. 'These'. WHERE title IN('All'. WHERE title LIKE LOWER('all these years'). 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'. Which character manipulation function always returns a numerical value? Mark for Review (1) Points . WHERE title LIKE INITCAP('%all these years'). Refer to Section 1 4.4. INSTR(last_name.1)) AS "User Passwords" FROM employees . SUBSTR(last_name.4.TRIM LPAD LENGTH (*) SUBSTR Incorrect.1)) AS "User Passwords" FROM employees SELECT CONCAT (employee_id. 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. 1. INSTR(last_name.4)) AS "User Passwords" FROM employees SELECT CONCAT (employee_id. Refer to Section 1 5.1.4)) AS "User Passwords" FROM employees (*) Incorrect. 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 . SUBSTR(last_name.SELECT CONCAT (employee_id. _______ and _______ clauses. (Choose two correct answers) Mark for Review (1) Points (Choose all correct answers) SELECT. Refer to Section 1 6. FROM.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. Single row functions may be used in ______. ALWAYS . ) Mark for Review (1) Points (Choose all correct answers) Multi-Row Functions (*) Column-Row Functions Single-Row Functions (*) Many-to-Many Functions Incorrect. ORDERS WHERE. Refer to Section 1 . ORDER BY (*) Incorrect.FROM. DECODE. Refer to Section 1 7. SELECT. WHERE. Which of the following are types of SQL functions? (Choose two correct answers. ORDER BY (*) SELECT. Character functions accept character arguments and only return character values. What does the following SQL SELECT statement return? SELECT UPPER( SUBSTR('Database Programming'.20)) FROM dual. True or False? Mark for Review (1) Points True . Mark for Review (1) Points Programming PROGRAMMING (*) Database DATABASE Incorrect. Refer to Section 1 9.8.'P'). INSTR('Database Programming'. Number Functions (Answer all questions in this section) 1. feedback. and question scores below.False (*) Correct Test: Quiz: Number Functions Review your answers. An asterisk (*) indicates a correct answer. 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 . The answer to the following script is 456. True or False? SELECT TRUNC(ROUND(456. Refer to Section 1 2.None of the above 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 (*) .98)) FROM dual Mark for Review (1) Points True False (*) Incorrect. Mark for Review (1) Points 01-JAN-04 (*) 01-JAN-03 01-JUL-03 01-AUG-03 . If hire_date has a value of '03-July-03'. Refer to Section 1 4. 'Year') FROM employees.TRUNC ROUND BINARY Incorrect. then what is the output from this code? SELECT ROUND(hire_date. .-1) FROM DUAL. Refer to Section 1 5. Mark for Review (1) Points 46 45.923.9 50 (*) None of the above Correct. Test: Quiz: Date Functions Review your answers. An asterisk (*) indicates a correct answer.Incorrect. and question scores below. What is the result of the following SQL Statement: SELECT ROUND(45. feedback. None of the above . (*) SELECT TRUNC(YEARS_BETWEEN(SYSDATE. 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 MONTHS_BETWEEN(SYSDATE.'19-MAR-79') /12 AS YEARS FROM DUAL.Date Functions (Answer all questions in this section) 1.'19-MAR-79') /12) AS YEARS FROM DUAL. Round and Trunc can be used on Date datatypes. Mark for Review (1) Points 17-Jan-04 11-Jan-95 11-Jul-94 (*) 17-Jul-94 . True or False? Mark for Review (1) Points True (*) False 3.Incorrect. What is the result of the following query? SELECT ADD_MONTHS ('11-JAN-94'.6) FROM dual. Refer to Section 1 2. 6) FROM dual. (*) 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 . Mark for Review (1) Points This in not a valid SQL statement. What is the result of the following query? SELECT ADD_YEARS ('11-JAN-94'.4. and question scores below. feedback. Mark for Review (1) Points 01-JAN-04 (*) 01-JAN-03 01-JUL-03 01-AUG-03 Test: Quiz: Conversion Functions Review your answers. If hire_date has a value of '03-July-03'. An asterisk (*) indicates a correct answer. 'Year') FROM employees.LAST_DAY (*) 6. Conversion Functions (Answer all questions in this section) . then what is the output from this code? SELECT ROUND(hire_date. (*) SELECT TO_CHAR(hire_date. SELECT TO_CHAR(hire_date. 'DDspth 'of' Month RRRR') FROM employees.1. You need to display the HIRE_DATE values in this format: 25th of July 2002. SELECT TO_CHAR(hire_date. Which SELECT statement would you use? Mark for Review (1) Points SELECT enroll_date(hire_date. 'DDTH "of" Month YYYY') FROM employees. 'ddth "of" Month YYYY') FROM employees. . 'DDspth "of" Month YYYY') FROM employees. '$99999.00') SALARY FROM employees (*) SELECT TO_CHAR(salary. True or False? . 6000 from the Employees table in the following format $6000. The following script will run successfully.00') SALARY FROM employees 3. Refer to Section 2 2. '$99999') SALARY FROM employees SELECT TO_CHAR(sal.00? Mark for Review (1) Points SELECT TO_CHAR(salary. Which statement will return the salary of e.Incorrect.g. '99999. '$99999.00') SALARY FROM employees SELECT TO_CHAR(salary. SELECT TO_CHAR(TO_DATE(“25-DEC-04” . null) Will the following query work:? SELECT * . 'Natacha Hansen'. 'Bob Bevan'.'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. MANAGER_ID VARCHAR2(6)) and contains the following rows: (1001. '200') (200. LAST_NAME VARCHAR2(10) NOT NULL. Yes. Functions can round a number to a specified decimal place. a. (*) No. 5. You will have to re-write the statement and perform explicit datatype conversion. because the datatypes of ID and MANAGER are different. because the WHERE-clause will not find any matching data No. Mark for Review (1) Points No. b and c are true. Oracle will perform implicit datatype conversion. (*) .FROM emps WHERE id = manager. Functions can convert upper case characters to lower case characters. Which statement is true about SQL functions? Mark for Review (1) Points Functions can convert values or text to another data type. None of the above statements are true. Refer to Section 2 . (*) The RR date format will interpret the year as 2089. 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. Refer to Section 2 6. Incorrect. The RR date format will interpret the year as 1989. and the YY date format will interpret the year as 1989. Both the YY and RR date formats will interpret the year as 2089. and the YY date format will interpret the year as 2089. Sysdate is 12-MAY-2004. Incorrect. -1 Vargas. feedback.2.null. null. null. 100 SELECT last_name. manager_id) what is the result of the following statement? DATA: King. -1 Kochhar. With the following data in Employees (last_name. manager_id.100 Vargas.Test: Quiz: Null Functions Review your answers.. Null Functions (Answer all questions in this section) 1.null Kochhar. Mark for Review (1) Points King. -1) comm FROM employees . 124 Zlotkey. and question scores below. NVL2(commission_pct. commission_pct. -1 . An asterisk (*) indicates a correct answer. 100 Vargas. what is the result of this statement? SELECT NVL(200/quantity. Mark for Review (1) Points zero . 124 Zlotkey. If quantity is a number datatype.Zlotkey.2 King. . -100 Statement will fail. 'zero') FROM inventory. -1 Kochhar. -1 Kochhar. -1 Vargas. 100 (*) 2. -1 Zlotkey. King. 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 . manager_id. Consider the following data in the Employees table: last_name commission_pct manager_id King null null Kochhar null 100 Vargas null 124 Zlotkey . 124 Zlotkey. 100 Vargas.4. 100 Vargas. . -1) comm FROM employees .2 (*) King.2 100 What is the result of the following statement: SELECT last_name. 100 . 124 Zlotkey. -1 Kochhar. -1 Kochhar. COALESCE(commission_pct. Mark for Review (1) Points Statement will fail King. 124 Zlotkey. 100 Vargas. Mark for Review (1) Points True False (*) Incorrect. . The following statement returns 0 (zero).2 5. Refer to Section 2 Test: Quiz: Conditional Expressions . null Kochhar.King. True or False? SELECT 121/NULL FROM dual. and question scores below. manager_id) what is the result of the following statement: DATA: King. Which of the following is a conditional expression used in SQL? Mark for Review (1) Points CASE (*) DESCRIBE WHERE NULLIF Incorrect. For the given data from Employees (last_name. Refer to Section 2 2. Conditional Expressions (Answer all questions in this section) 1. An asterisk (*) indicates a correct answer.Review your answers. null . feedback. A N Other King. Null Kochhar. King De Haan. A N Other (*) . King Hunold. 100. 103 SELECT last_name. 'King'. A N Other Ernst. 'A N Other') FROM employees Mark for Review (1) Points King. A N Other Kochhar. King Hunold.Kochhar. King De Haan. 100 Hunold. DECODE(manager_id. 100 De Haan. A N Other Ernst. 102 Ernst. 'Good' or 'Excellent' depending on the salary value? Mark for Review (1) Points . salaries and a rating of 'Low'. De Haan 3. King. True or False? Mark for Review (1) Points True (*) False Correct 4. King Hunold. 'Medium'. Kochhar Ernst. King De Haan. However. A N Other Kochhar.Invalid statement. DECODE is specific to Oracle syntax. CASE and DECODE evaluate expressions in a similar way to IF-THEN-ELSE logic. Which statement will return a listing of last names. SELECT last_name. (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 sal<5000 THEN 'Low' WHEN sal<10000 THEN 'Medium' WHEN sal<20000 THEN 'Good' ELSE 'Excellent' .salary. (*) SELECT last_name.sal. (CASE WHEN salary<5000 THEN 'Low' WHEN salary<10000 THEN 'Medium' WHEN salary<20000 THEN 'Good' ELSE 'Excellent' END) qualified_salary FROM employees. (RATING WHEN salary<5000 THEN 'Low' WHEN salary<10000 THEN 'Medium' WHEN salary<20000 THEN 'Good' ELSE 'Excellent' END) qualified_salary FROM employees. feedback. SELECT last_name. If table A has 10 rows and table B has 5 rows. Test: Quiz: Cartesian Product and the Join Operations Review your answers. An asterisk (*) indicates a correct answer.END) qualified_salary FROM employees. how many rows will be returned if you perform an equi-join on those two tables? Mark for Review (1) Points . Cartesian Product and the Join Operations (Answer all questions in this section) 1.salary. and question scores below. 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. Correct 3. When the same column name appears in more than one table of the query.50 It depends on the data found in the two tables. Will the following statement work? . Only when query speed and database performance is a concern. (*) Never. (*) 5 10 2. Mark for Review (1) Points No. Yes. Oracle will not allow joins in the Where clause. A selection of rows from the first table only. (*) No. 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. Oracle will return a column ambiguously defined error. Oracle will resolve which department_id colum comes from which table. there are no syntax errors in the statement. last_name FROM employees. . 4.SELECT department_name. (*) A selection of matched rows from both tables. departments WHERE department_id = department_id. Yes. A Syntax error. True or False? Mark for Review (1) Points True (*) False 6. Oracle proprietary JOINS can use the WHERE clause for conditions other than the join-condition. Refer to Section 3 5. 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 .Incorrect. and question scores below.Test: Quiz: Nonequijoins Review your answers. 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 . feedback. salary BETWEEN j.2. e.. True or False? Mark for Review (1) Points True (*) False 3.highest_sal. Which of the following operators is/are typically used in a nonequijoin? Mark for Review (1) Points NOT OR IN >=. SELECT e. BETWEEN .salary.AND (*) . j.lowest_sal AND j.last_name. job_grades j WHERE e.. The following statement is an example of a nonequi-join. <=.grade_level FROM employees e. feedback.last_name FROM employees e. 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. Refer to Section 3 Test: Quiz: Outer Joins Review your answers.Incorrect. An asterisk (*) indicates a correct answer.department_id (*) .department_id(+) = d. Outer Joins (Answer all questions in this section) 1. departments d WHERE Mark for Review (1) Points e. and question scores below.department_name. e. country_name. 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. Refer to Section 3 3.department_id(+) e.department_id(+) = d.department_name .department_id = d.department_id 2. d.department_id(+) e.department_id = d.e. The following is a valid outer join statement: SELECT c. Which type of join should you use to display the data? Mark for Review (1) Points Equijoin Self join Outer join (*) Nonequi-Join Incorrect. FROM countries c. departments d WHERE c.country_id (+) = d. Which symbol is used to perform an outer join? Mark for Review (1) Points * || (+) (*) # .country_id (+) True or False? Mark for Review (1) Points True False (*) 4. 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 .Correct Test: Quiz: Self Joins Review your answers. and question scores below. Self Joins (Answer all questions in this section) 1. feedback. An asterisk (*) indicates a correct answer. manager_id = w. m.employee_id AND w.hire_date. m.last_name.manager_id != m.last_name.employee_id AND w. employees m WHERE w.last_name.hire_date.last_name.hire_date FROM employees w .hire_date > m.manager_id = m. m.hire_date.hire_date FROM employees w .employee_id AND w.hire_date FROM employees w . employees w WHERE w.hire_date FROM employees w . w. m.hire_date < m. m.last_name. 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.hire_date. w. w.last_name.2.hire_date SELECT w.hire_date < w. employees m WHERE w.hire_date < m.hire_date SELECT w.hire_date SELECT w. w.last_name.hire_date (*) .employee_id AND w.last_name. m. m. employees m WHERE w. m.manager_id = m. manager_id FROM employees e. departments m WHERE e.3. .employee_id.employee_id.manager_id FROM employees e.manager_id FROM employees e NATURAL JOIN employee m. SELECT e. employees m WHERE m. m.employee_id.employee_id = m.manager_id.manager_id.manager_id FROM employees e. (*) SELECT e.manager_id. Which SELECT statement implements a self join ? Mark for Review (1) Points SELECT e.employee_id = e. m. m. manager m WHERE e.employee_id = m. m. SELECT e.employee_id. Refer to Section 3 Test: Quiz: Cross joins and Natural Joins Review your answers.Incorrect. An asterisk (*) indicates a correct answer. and question scores below. The ___________ join is the ANSI-standard syntax used to generate a Cartesian product. Mark for Review (1) Points NATURAL ALL FULL CROSS (*) Incorrect. feedback. Cross joins and Natural joins 1. Refer to Section 4 . 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. True or False? Mark for Review (1) Points True False (*) 3.2. one column to the next column. The join column must be included in the select statement when you use the NATURAL JOIN clause. A NATURAL JOIN is based on: Mark for Review . Refer to Section 4 4. exhausting all possibilities All rows that do not match in the WHERE clause are displayed Incorrect. The following is a valid SQL statement. e.location_id. SELECT e. Refer to Section 4 Test: Quiz: Join Clauses Review your answers. An asterisk (*) indicates a correct answer.employee_id. and question scores below.last_name. feedback. department_id . Join Clauses (Answer all questions in this section) 1.(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. d. Mark for Review (1) Points NATURAL ON ON WHEN USING (*) . True or False? Mark for Review (1) Points True (*) False 2.FROM employees e JOIN departments d USING (department_id) . The keywords JOIN _____________ should be used to join tables with the same column names but different datatypes. Correct 3. 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 (*) . True or False? Mark for Review (1) Points True (*) False 4. You can do nonequi-joins with ANSI-Syntax. 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? 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 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); 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 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) ; 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 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) 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 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. 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) 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 (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 (*) 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 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) 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 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 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 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) 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; (*) 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 (*) 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; 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 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 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: 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 (*) 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 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 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 (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 (*) 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 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); 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 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 (*) An asterisk (*) indicates a correct answer.False Correct 8. Multiple-row subqueries must have NOT. and question scores below. . 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. If the employees table have 7 rows how many rows are inserted into the copy_emps table with the following statement: .Insert Statement (Answer all questions in this section) 1. True or False? Mark for Review (1) Points True (*) False 3. When inserting a new row the null keyword can be included in the values list for any null column. 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 Correct 2. INSERT INTO copy_emps (employee_id. 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'. first_name. first_name. as there is no WHERE-clause on the subquery. last_name. salary. salary. Use the SYSDATE function. Simply use the keyword DATE in the insert statement. 4. department_id) SELECT employee_id. 7 rows. 10 rows will be created. last_name. (*) Use the TODAYS_DATE function. department_id FROM employees Mark for Review (1) Points No rows. (*) No rows. as the select statement is invalid. . as you cannot use subqueries in an insert statement. address. state. state. 'Katie'. (*) INSERT INTO customers (id 145. state. zip 98008. '92 Chico Way'. city. phone_number). phone_number) VALUES ("145". '92 Chico Way'. INSERT INTO customers (id. city 'Los Angeles'. 'CA'. first_name. "8586667641"). INSERT INTO customers (id. 98008. phone_number 8586667641). "98008". 'Hernandez'. first_name. last_name. zip. city. last_name 'Hernandez'. 8586667641). Correct . address. state 'CA'.5. zip. first_name 'Katie'. 'Los Angeles'. city. zip. address. first_name. address '92 Chico Way'. last_name. phone_number) VALUES (145. 'Katie'. 'Hernandez'. 'Los Angeles'. last_name. 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. 'CA'. No. VALUES.6. or DIST customers DESCRIBE customers. . you can only create one row at a time when using the VALUES clause. there is no such thing as INSERT …. you can just list as many rows as you want. or DEF customers Incorrect. or DESC customers (*) DEFINE customers. or SEE customers DISTINCT customers. 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. which of the following is correct? Mark for Review (1) Points SHOW customers. (*) Yes. just remember to separate the rows with commas. To return a table summary on the customers table. 8. When inserting rows into a table all columns must be given values. Refer to Section 7 . 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. Updating Column Values and Deleting Rows (Answer all questions in this section) 1. One row will be deleted. 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%').Test: Quiz: Updating Column Values and Deleting Rows Review your answers. 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. and question scores below. Assuming there are no Foreign Keys on the EMPLOYEES table. Mark for Review (1) Points No rows will be deleted. if the following subquery returns one row. An asterisk (*) indicates a correct answer. (*) . feedback. Using your knowledge of the employees table. as there exists one employee called King. no data will be changed. How many rows will be deleted from the employees table with the following statement? DELETE FROM employees WHERE last_name = 'king'. what would be the result of the following statement: DELETE FROM employees.All rows in the EMPLOYEES table will be deleted. (*) One will will be deleted. (*) . regardless of their department_id. Mark for Review (1) Points All the rows in the employees table will be deleted. All rows with last_name = 'King' will be deleted. No rows will be deleted. as no employees match the WHERE-clause. Mark for Review (1) Points Nothing. 3. All rows in the employees table will be deleted if there are no constraints on the table. 2. this will not work No. (*) The statement will fail. 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).e. because the subqueries are returning data from different rows No. Is the following statement valid. . this statement will return an error. Mark for Review (1) Points Yes. 4. Deletes employee number 100.The first row in the employees table will be deleted. is it allowed to update rows in one table. this is a perfectly valid statement. i. Correct 6. Does nothing. To change an existing row in a table. (*) Inserts a new row into the students table. you can use the UPDATE and INSERT statements.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. the as you cannot use subqueries in update statements. True or False? Mark for Review (1) Points . 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. Deletes student 17's lunch_number and inserts a new value from student 19. and question scores below. Default Values and the Merge Statement (Answer all questions in this section) 1. feedback. An asterisk (*) indicates a correct answer. The MERGE function combines the: Mark for Review (1) Points CREATE and UPDATE commands INSERT and UPDATE commands (*) .True False (*) Correct Test: Quiz: Default Values and the Merge Statement Review your answers. If a default value was set for a null column.ALTER and UPDATE commands all of the above Incorrect. However. if no default value was set when the column was created. 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. Oracle inserts an empty space. True or False? Mark for Review (1) Points True False (*) . Oracle sets the column to the default value. Refer to Section 7 2. 6543). 'Roberts'. Which statement below will not insert a row of data onto a table? Mark for Review (1) Points INSERT INTO student_table (id. lunch_num) VALUES (143352. INSERT INTO student_table (id. lname. 'Roberts'. 6543). 'Cameron'. (*) Incorrect. lunch_num) VALUES (143354. INSERT INTO student_table VALUES (143354. 6543).Correct 4. 'Roberts'. DEFAULT). INSERT INTO (id. fname. lname. 'Cameron'. fname. lunch_num) VALUES (143354. Refer to Section 7 . 'Roberts'. 'Cameron'. fname. 'Cameron'. lname. You assign the hire_date column a DATE datatype with a DEFAULT value of 0 (zero). they can be added faster by allowing the 0's (zeroes) to be automatically specified. When new employee records are entered. The default value must match the DATE datatype of the column. True or False? Mark for Review (1) Points True (*) False 6. Mark for Review (1) Points A great idea. the 0 (zero) will be automatically specified. In developing the Employees table. 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. you create a column called hire_date. A bad idea. This is __________. if no hire_date is specified.5. Both a and b are correct. A user can come back later and enter the correct hire_date. When a new employee record is entered. (*) . A great idea. Refer to Section 7 Page 1 of 1 .Incorrect. . . . You need to return a portion of each employee's last name. beginning with the first character up to the fifth character.Section 1 Lesson 1 (Answer all questions in this section) 1. Which character function should you use? Mark for Review (1) Points INSTR . The last name and the format of the salary limited to 15 digits to the left of the decimal and the column labeled SALARY. 15. The last name and salary for all employees with the format of the salary 15 characters long. (*) The query will result in an error: "ORA-00923: FROM keyword not found where expected. What will the following SQL statement display? SELECT last_name. Refer to Section 1 3. size of 15 and the column labeled SALARY. 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 . leftpadded with the $ and the column labeled SALARY. LPAD(salary." Incorrect. Refer to Section 1 2. Mark for Review (1) Points The last name of employees that have a salary that includes a $ in the value.TRUNC SUBSTR (*) CONCAT Incorrect. '$')SALARY FROM employees. NVL2 TRIM (*) Incorrect. Evaluate this SELECT statement: SELECT LENGTH(email) FROM employees. Refer to Section 1 4. The number of characters for each value in the EMAIL column in the EMPLOYEES table. You issue this SQL statement: SELECT INSTR ('organizational sales'. 'al') FROM dual. The email address of each employee in the EMPLOYEES table. Correct 5. (*) The maximum number of characters allowed in the EMAIL column. What will this SELECT statement display? Mark for Review (1) Points The longest e-mail address in the EMPLOYEES table. Which value is returned by this command? Mark for Review (1) Points 1 . 00 809090 LOAFER 89098 10. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name. LOWER CONCAT.00 890890 LOAFER 89789 14. 1.00 869506 SANDAL 89690 15. SUBSTR. first_name)).00 968950 SANDAL 85909 10. SUBSTR. CONCAT LOWER. CONCAT. Refer to Section 1 6. In which order are the functions evaluated? Mark for Review (1) Points LOWER. 5) "ID" FROM employee.2 13 (*) 17 Incorrect. CONCAT. LOWER (*) Incorrect.00 . Refer to Section 1 7. SUBSTR SUBSTR. The STYLES table contains this data: STYLE_ID STYLE_NAME CATEGORY COST 895840 SANDAL 85940 12.00 857689 HEEL 85940 11. -2. 2.-1) FROM dual.758960 SANDAL 86979 12. Which script did you use? Mark for Review (1) Points SELECT INSTR(category.2) FROM styles WHERE style_id = 895840.00 You query the database and return the value 79.2) FROM styles WHERE style_id = 758960. SELECT SUBSTR(category.2) FROM styles WHERE style_id = 895840. -2. You issue this SQL statement: SELECT TRUNC(751. . SELECT INSTR(category. Refer to Section 1 Section 1 Lesson 2 (Answer all questions in this section) 8. SELECT SUBSTR(category.367. 2.2) FROM styles WHERE style_id = 895840. (*) Incorrect. Refer to Section 1 Lesson 3 10.Which value does this statement display? Mark for Review (1) Points 700 750 (*) 751 751. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'? Mark for Review (1) Points SELECT TRUNC(hire_date. Incorrect. 'MON') FROM employees. SELECT TRUNC(hire_date.3 Correct 9. 'MONTH') FROM employees. SELECT ROUND(hire_date. (*) SELECT ROUND(hire_date. but NOT character . 'MONTH') FROM employees. Which two functions can be used to manipulate number or date column values. 'MI') FROM employees. (SYSDATE-hire_date)/7 DISPLAY WEEKS FROM employees WHERE department id = 90. (SYSDATE-hire_date)/7 AS WEEKS FROM employees WHERE department_id = 90. (*) SELECT last name.) 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.column values? (Choose two. You want to create a report that displays all orders and their amounts that were placed during the month of January. Which function should you use? Mark for Review (1) Points ROUND BETWEEN ADD_MONTHS MONTHS_BETWEEN (*) Incorrect.SELECT last_name. # of WEEKS FROM employees WHERE department_id = 90. You want the orders with the highest amounts to appear first. SELECT orderid. You need to display the number of months between today's date and each employee's hiredate. total . Which query should you issue? Mark for Review (1) Points SELECT orderid. Incorrect. (SYSDATE-hire_date)AS WEEK FROM employees WHERE department_id = 90. total FROM orders WHERE order_date LIKE '01-jan-02' AND '31-jan-02' ORDER BY total DESC. SELECT last_name. Refer to Section 1 12. Refer to Section 1 13. 31-jan-02 ) ORDER BY total.FROM orders WHERE order_date IN ( 01-jan-02 . Refer to Section 1 14. SELECT orderid. (*) SELECT orderid. total FROM orders WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02' ORDER BY total DESC. Incorrect. You need to subtract three months from the current date. total FROM orders WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02' ORDER BY total DESC. Refer to Section 1 15. Which function should you use? Mark for Review (1) Points ROUND TO_DATE ADD_MONTHS (*) MONTHS_BETWEEN Incorrect. Which SELECT statement will return a numeric value? Mark for Review (1) Points . SELECT SYSDATE + 600 / 24 .
Copyright © 2024 DOKUMEN.SITE Inc.